Skip to content

Commit

Permalink
Using a dataKey to specify a part of a JSON file when using `load.p…
Browse files Browse the repository at this point in the history
…ack` would fail as it wouldn't correctly assign the right part of the pack file to the Loader. You can now use this parameter properly. Fix #6001
  • Loading branch information
photonstorm committed Nov 29, 2022
1 parent 2b4332a commit 5ae9cf7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/loader/filetypes/PackFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ var PackFile = new Class({
this.data = JSON.parse(this.xhrLoader.responseText);
}

if (this.data.hasOwnProperty('files') && this.config)
{
var newData = {};

newData[this.config] = this.data;

this.data = newData;
}

// Let's pass the pack file data over to the Loader ...
this.loader.addPack(this.data, this.config);

Expand Down Expand Up @@ -188,7 +197,7 @@ var PackFile = new Class({
*
* @return {this} The Loader instance.
*/
FileTypesManager.register('pack', function (key, url, packKey, xhrSettings)
FileTypesManager.register('pack', function (key, url, dataKey, xhrSettings)
{
// Supports an Object file definition in the key argument
// Or an array of objects in the key argument
Expand All @@ -203,7 +212,7 @@ FileTypesManager.register('pack', function (key, url, packKey, xhrSettings)
}
else
{
this.addFile(new PackFile(this, key, url, xhrSettings, packKey));
this.addFile(new PackFile(this, key, url, xhrSettings, dataKey));
}

return this;
Expand Down

0 comments on commit 5ae9cf7

Please sign in to comment.