Skip to content
Snippets Groups Projects
Commit 29501442 authored by Christian Adamski's avatar Christian Adamski
Browse files

#3507996 Load feature scripts before initializing map

parent 7caf94ae
No related branches found
No related tags found
1 merge request!90#3507996 Load feature scripts before initializing map
Pipeline #443957 failed
......@@ -107,6 +107,17 @@ export class GeolocationMapBase {
.then(() => {
return Promise.all(stylesheetLoads);
})
.then(() => {
// Some features depend on libraries loaded AFTER main script but BEFORE instantiating.
const featureScriptLoads = [];
Object.keys(this.settings.features ?? {}).forEach((featureName) => {
const featureScripts = this.settings.features[featureName]?.scripts || [];
featureScripts.forEach((featureScript) => {
featureScriptLoads.push(Drupal.geolocation.addScript(featureScript));
});
});
return Promise.all(featureScriptLoads);
})
.then(() => {
return this;
});
......@@ -123,12 +134,6 @@ export class GeolocationMapBase {
return null;
}
const scripts = featureSettings.scripts || [];
const scriptLoads = [];
scripts.forEach((script) => {
scriptLoads.push(Drupal.geolocation.addScript(script));
});
const asyncScripts = featureSettings.async_scripts || [];
const asyncScriptLoads = [];
asyncScripts.forEach((script) => {
......@@ -141,10 +146,7 @@ export class GeolocationMapBase {
stylesheetLoads.push(Drupal.geolocation.addStylesheet(stylesheet));
});
return Promise.all(scriptLoads)
.then(() => {
return Promise.all(asyncScriptLoads);
})
return Promise.all(asyncScriptLoads)
.then(() => {
return Promise.all(stylesheetLoads);
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment