From 049d363bb22216ae7fa8e9fd7c62c2c2dcda9b88 Mon Sep 17 00:00:00 2001
From: SS <66886825+EarlMilktea@users.noreply.github.com>
Date: Fri, 25 Oct 2024 04:57:41 +0900
Subject: [PATCH] :recycle: Prevent double-init
---
js/reveal.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/js/reveal.js b/js/reveal.js
index cb990969176..29724017412 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -130,12 +130,16 @@ export default function( revealElement, options ) {
if( !revealElement ) throw 'Unable to find presentation root (
).';
- initialized = true;
+ // Skip initialization if initialize is already called
+ if( Object.is( revealElement, dom.wrapper ) ) return;
// Cache references to key DOM elements
+ // Need to set immediately after Object.is check
dom.wrapper = revealElement;
dom.slides = revealElement.querySelector( '.slides' );
+ initialized = true;
+
if( !dom.slides ) throw 'Unable to find slides container (
).';
// Compose our config object in order of increasing precedence:
@@ -670,6 +674,10 @@ export default function( revealElement, options ) {
slide.removeAttribute( 'aria-hidden' );
} );
+ // Free cached references to allow re-initialization
+ // Need to be the last step of destroy
+ delete dom.wrapper;
+ delete dom.slides;
}
/**