Bladeren bron

prevent same plugin from being registered twice

Hakim El Hattab 5 jaren geleden
bovenliggende
commit
7b62a0f356
1 gewijzigde bestanden met toevoegingen van 10 en 5 verwijderingen
  1. 10 5
      js/reveal.js

+ 10 - 5
js/reveal.js

@@ -1558,12 +1558,17 @@
 	 */
 	function registerPlugin( id, plugin ) {
 
-		plugins[id] = plugin;
+		if( plugins[id] === undefined ) {
+			plugins[id] = plugin;
 
-		// If a plugin is registered after reveal.js is loaded,
-		// initialize it right away
-		if( loaded && typeof plugin.init === 'function' ) {
-			plugin.init();
+			// If a plugin is registered after reveal.js is loaded,
+			// initialize it right away
+			if( loaded && typeof plugin.init === 'function' ) {
+				plugin.init();
+			}
+		}
+		else {
+			console.warn( 'reveal.js: "'+ id +'" plugin has already been registered' );
 		}
 
 	}