fix error when reveal.js was initialized with no plugins
parent
6410ed15aa
commit
b180d94e02
41
js/reveal.js
41
js/reveal.js
|
@ -539,30 +539,39 @@
|
||||||
|
|
||||||
var pluginsToInitialize = Object.keys( plugins ).length;
|
var pluginsToInitialize = Object.keys( plugins ).length;
|
||||||
|
|
||||||
var afterPlugInitialized = function() {
|
// If there are no plugins, skip this step
|
||||||
if( --pluginsToInitialize === 0 ) {
|
if( pluginsToInitialize === 0 ) {
|
||||||
loadAsyncDependencies();
|
loadAsyncDependencies();
|
||||||
}
|
}
|
||||||
};
|
// ... otherwise initialize plugins
|
||||||
|
else {
|
||||||
|
|
||||||
for( var i in plugins ) {
|
var afterPlugInitialized = function() {
|
||||||
|
if( --pluginsToInitialize === 0 ) {
|
||||||
|
loadAsyncDependencies();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var plugin = plugins[i];
|
for( var i in plugins ) {
|
||||||
|
|
||||||
// If the plugin has an 'init' method, invoke it
|
var plugin = plugins[i];
|
||||||
if( typeof plugin.init === 'function' ) {
|
|
||||||
var callback = plugin.init();
|
|
||||||
|
|
||||||
// If the plugin returned a Promise, wait for it
|
// If the plugin has an 'init' method, invoke it
|
||||||
if( callback && typeof callback.then === 'function' ) {
|
if( typeof plugin.init === 'function' ) {
|
||||||
callback.then( afterPlugInitialized );
|
var callback = plugin.init();
|
||||||
|
|
||||||
|
// If the plugin returned a Promise, wait for it
|
||||||
|
if( callback && typeof callback.then === 'function' ) {
|
||||||
|
callback.then( afterPlugInitialized );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
afterPlugInitialized();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
afterPlugInitialized();
|
afterPlugInitialized();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
afterPlugInitialized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue