Skip to content

Commit

Permalink
fix exception when destroying uninitialized reveal instance (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Mar 22, 2024
1 parent 924bdb6 commit 0799c8f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default function( revealElement, options ) {
// Configuration defaults, can be overridden at initialization time
let config = {},

// Flags if initialize() has been invoked for this reveal instance
initialized = false,

// Flags if reveal.js is loaded (has dispatched the 'ready' event)
ready = false,

Expand Down Expand Up @@ -127,6 +130,8 @@ export default function( revealElement, options ) {

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

initialized = true;

// Cache references to key DOM elements
dom.wrapper = revealElement;
dom.slides = revealElement.querySelector( '.slides' );
Expand Down Expand Up @@ -604,6 +609,10 @@ export default function( revealElement, options ) {
*/
function destroy() {

// There's nothing to destroy if this instance hasn't been
// initialized yet
if( initialized === false ) return;

removeEventListeners();
cancelAutoSlide();
disablePreviewLinks();
Expand Down

0 comments on commit 0799c8f

Please sign in to comment.