mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-07-31 11:50:25 +02:00
fix exception when destroying uninitialized reveal instance (closes #3593)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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' );
|
||||
@@ -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();
|
||||
|
Reference in New Issue
Block a user