Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double initialization #3696

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,16 @@ export default function( revealElement, options ) {

if( !revealElement ) throw 'Unable to find presentation root (<div class="reveal">).';

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 (<div class="slides">).';

// Compose our config object in order of increasing precedence:
Expand Down Expand Up @@ -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;
}

/**
Expand Down