Skip to content

Commit

Permalink
fix(match2): battle royale issue with matchids starting with a number…
Browse files Browse the repository at this point in the history
… and incorrect caching (#5118)

fix battle royale template transclusion
  • Loading branch information
KilMer56 authored Nov 21, 2024
1 parent 19acd67 commit c0ab32d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions javascript/commons/BattleRoyale.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ liquipedia.battleRoyale = {
}
}
} );
obs.observe( document.querySelector( `[data-js-battle-royale-id=${ instanceId }]` ) );
obs.observe( document.querySelector( `[data-js-battle-royale-id="${ instanceId }"]` ) );
},

implementOnWindowResize: function( instanceId ) {
Expand Down Expand Up @@ -305,11 +305,11 @@ liquipedia.battleRoyale = {
const matchId = matchButton ? matchButton.dataset.jsBattleRoyaleMatchid : null;
const gameId = gameTab.dataset.jsBattleRoyaleGameIdx;

if ( loadTemplate && !this.loadedTabs[ battleRoyaleId ] ) {
if ( loadTemplate && !this.loadedTabs[ battleRoyaleId ][ matchContentId ] ) {
this.callTemplate( battleRoyaleId, matchId, gameId, matchContentId, () => {
this.buildBattleRoyaleMapMatchContents( battleRoyaleId, document.querySelector(
`[data-js-battle-royale-content-id="${ matchContentId }"]` ), true );
this.loadedTabs[ battleRoyaleId ] = true;
this.loadedTabs[ battleRoyaleId ][ matchContentId ] = true;
this.updateGameTabDisplay( battleRoyaleId, matchContentId, gameTab );
this.makeCollapsibles( battleRoyaleId );
this.battleRoyaleMap[ battleRoyaleId ].gameTabs[ matchContentId ].forEach(
Expand All @@ -336,7 +336,7 @@ liquipedia.battleRoyale = {
}
} );

if ( this.loadedTabs[ battleRoyaleId ] ) {
if ( this.loadedTabs[ battleRoyaleId ][ matchContentId ] ) {
const gamePanels = this.battleRoyaleMap[ battleRoyaleId ].gamePanels[ matchContentId ];
Object.keys( gamePanels ).forEach( ( gamePanelKey ) => {
// match the game tab with the correct game panel
Expand Down Expand Up @@ -415,7 +415,7 @@ liquipedia.battleRoyale = {
const targetId = node.dataset.jsBattleRoyaleContentTargetId;
this.battleRoyaleMap[ battleRoyaleId ]
.gamePanels[ matchContentId ][ targetId ] =
matchContent.querySelector( '#' + targetId );
document.getElementById( targetId );

const panel = this.battleRoyaleMap[ battleRoyaleId ]
.gamePanels[ matchContentId ][ targetId ];
Expand Down Expand Up @@ -681,12 +681,12 @@ liquipedia.battleRoyale = {
init: function() {
Array.from( document.querySelectorAll( '[ data-js-battle-royale-id ]' ) ).forEach( ( battleRoyaleElement ) => {
this.battleRoyaleInstances[ battleRoyaleElement.dataset.jsBattleRoyaleId ] = battleRoyaleElement;
this.loadedTabs[ battleRoyaleElement.dataset.jsBattleRoyaleId ] = false;

this.makeSortableTable( battleRoyaleElement );
} );

Object.keys( this.battleRoyaleInstances ).forEach( ( battleRoyaleId ) => {
this.loadedTabs[ battleRoyaleId ] = {};

// create object based on id
this.buildBattleRoyaleMap( battleRoyaleId );

Expand All @@ -711,6 +711,7 @@ liquipedia.battleRoyale = {
const matchId = matchButton.dataset.jsBattleRoyaleMatchid;
const matchContentId = matchButton.dataset.targetId;
const gameTabs = this.battleRoyaleMap[ battleRoyaleId ].gameTabs[ matchContentId ];
this.loadedTabs[ battleRoyaleId ][ matchContentId ] = false;

if ( matchId && matchContentId && Array.isArray( gameTabs ) && gameTabs.length ) {
// Set on first panel on init
Expand Down

0 comments on commit c0ab32d

Please sign in to comment.