diff --git a/js/reveal.js b/js/reveal.js
index 3cc1caec979aa5ffbda7bac979cfbcd1e8428398..a0b92acf7f99d6543954b78fa35a0806f6071908 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -716,6 +716,10 @@
 
 		container.appendChild( element );
 
+		// If backgrounds are being recreated, clear old classes
+		slide.classList.remove( 'has-dark-background' );
+		slide.classList.remove( 'has-light-background' );
+
 		// If this slide has a background color, add a class that
 		// signals if it is light or dark. If the slide has no background
 		// color, no class will be set