tweak plugin initialization to enable multi-instance plugins

This commit is contained in:
Hakim El Hattab
2020-04-17 14:10:56 +02:00
parent 7e72b10fa5
commit e58502b3fb
20 changed files with 128 additions and 110 deletions

View File

@ -56,7 +56,7 @@ export default class Plugins {
scriptsToLoad = scripts.length;
const scriptLoadedCallback = (s) => {
if( typeof s.callback === 'function' ) s.callback();
if( s && typeof s.callback === 'function' ) s.callback();
if( --scriptsToLoad === 0 ) {
this.initPlugins().then( resolve );
@ -69,9 +69,13 @@ export default class Plugins {
this.registerPlugin( s );
scriptLoadedCallback( s );
}
else {
else if( typeof s.src === 'string' ) {
loadScript( s.src, () => scriptLoadedCallback(s) );
}
else {
console.warn( 'Unrecognized plugin format', s );
scriptLoadedCallback();
}
} );
}
else {