From e034f28091e822d386cb0c1f23641d55516f9f94 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Tue, 10 Sep 2013 15:28:15 +0100 Subject: [PATCH] Bail out earlier when displaying a modal for a non-existent tiddler --- core/modules/utils/dom/modal.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/modules/utils/dom/modal.js b/core/modules/utils/dom/modal.js index 210a8cb48..aeca69a1b 100644 --- a/core/modules/utils/dom/modal.js +++ b/core/modules/utils/dom/modal.js @@ -27,10 +27,12 @@ Options include: Modal.prototype.display = function(title,options) { options = options || {}; var self = this, - duration = $tw.utils.getAnimationDuration(); - // Up the modal count and adjust the body class - this.modalCount++; - this.adjustPageClass(); + duration = $tw.utils.getAnimationDuration(), + tiddler = this.wiki.getTiddler(title); + // Don't do anything if the tiddler doesn't exist + if(!tiddler) { + return; + } // Create the wrapper divs var wrapper = document.createElement("div"), modalBackdrop = document.createElement("div"), @@ -41,12 +43,10 @@ Modal.prototype.display = function(title,options) { modalLink = document.createElement("a"), modalFooter = document.createElement("div"), modalFooterHelp = document.createElement("span"), - modalFooterButtons = document.createElement("span"), - tiddler = this.wiki.getTiddler(title); - // Don't do anything if the tiddler doesn't exist - if(!tiddler) { - return; - } + modalFooterButtons = document.createElement("span"); + // Up the modal count and adjust the body class + this.modalCount++; + this.adjustPageClass(); // Add classes $tw.utils.addClass(wrapper,"modal-wrapper"); $tw.utils.addClass(modalBackdrop,"modal-backdrop");