Преглед на файлове

fix error when reveal.js was initialized with no plugins

Hakim El Hattab преди 5 години
родител
ревизия
b180d94e02
променени са 1 файла, в които са добавени 25 реда и са изтрити 16 реда
  1. 25 16
      js/reveal.js

+ 25 - 16
js/reveal.js

@@ -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();
+
 			}
 
 		}