Skip to content

Commit

Permalink
fix error when reveal.js was initialized with no plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Mar 14, 2019
1 parent 6410ed1 commit b180d94
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,30 +539,39 @@

var pluginsToInitialize = Object.keys( plugins ).length;

var afterPlugInitialized = function() {
if( --pluginsToInitialize === 0 ) {
loadAsyncDependencies();
}
};
// If there are no plugins, skip this step
if( pluginsToInitialize === 0 ) {
loadAsyncDependencies();
}
// ... otherwise initialize plugins
else {

var afterPlugInitialized = function() {
if( --pluginsToInitialize === 0 ) {
loadAsyncDependencies();
}
};

for( var i in plugins ) {
for( var i in plugins ) {

var plugin = plugins[i];
var plugin = plugins[i];

// If the plugin has an 'init' method, invoke it
if( typeof plugin.init === 'function' ) {
var callback = plugin.init();
// If the plugin has an 'init' method, invoke it
if( typeof plugin.init === 'function' ) {
var callback = plugin.init();

// If the plugin returned a Promise, wait for it
if( callback && typeof callback.then === 'function' ) {
callback.then( afterPlugInitialized );
// If the plugin returned a Promise, wait for it
if( callback && typeof callback.then === 'function' ) {
callback.then( afterPlugInitialized );
}
else {
afterPlugInitialized();
}
}
else {
afterPlugInitialized();
}
}
else {
afterPlugInitialized();

}

}
Expand Down

0 comments on commit b180d94

Please sign in to comment.