From 219beb13cc77bae54637e6d0d737153c9371da40 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Wed, 9 Jun 2021 11:18:15 +0200 Subject: [PATCH] Add test to storyviews if targetElement is null (#5767) * Update classic.js * Update pop.js * Update zoomin.js * simplify test in classic.js * simplify test in pop.js * simplify test in zoomin.js --- core/modules/storyviews/classic.js | 6 +++--- core/modules/storyviews/pop.js | 6 +++--- core/modules/storyviews/zoomin.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/modules/storyviews/classic.js b/core/modules/storyviews/classic.js index 653a7e437..c2848c435 100644 --- a/core/modules/storyviews/classic.js +++ b/core/modules/storyviews/classic.js @@ -27,7 +27,7 @@ ClassicStoryView.prototype.navigateTo = function(historyInfo) { var listItemWidget = this.listWidget.children[listElementIndex], targetElement = listItemWidget.findFirstDomNode(); // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { return; } if(duration) { @@ -43,7 +43,7 @@ ClassicStoryView.prototype.insert = function(widget) { if(duration) { var targetElement = widget.findFirstDomNode(); // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { return; } // Get the current height of the tiddler @@ -83,7 +83,7 @@ ClassicStoryView.prototype.remove = function(widget) { widget.removeChildDomNodes(); }; // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { removeElement(); return; } diff --git a/core/modules/storyviews/pop.js b/core/modules/storyviews/pop.js index bb66606c5..e2634e3d5 100644 --- a/core/modules/storyviews/pop.js +++ b/core/modules/storyviews/pop.js @@ -24,7 +24,7 @@ PopStoryView.prototype.navigateTo = function(historyInfo) { var listItemWidget = this.listWidget.children[listElementIndex], targetElement = listItemWidget.findFirstDomNode(); // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { return; } // Scroll the node into view @@ -35,7 +35,7 @@ PopStoryView.prototype.insert = function(widget) { var targetElement = widget.findFirstDomNode(), duration = $tw.utils.getAnimationDuration(); // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { return; } // Reset once the transition is over @@ -77,7 +77,7 @@ PopStoryView.prototype.remove = function(widget) { } }; // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { removeElement(); return; } diff --git a/core/modules/storyviews/zoomin.js b/core/modules/storyviews/zoomin.js index 9ece5823f..b2796e953 100644 --- a/core/modules/storyviews/zoomin.js +++ b/core/modules/storyviews/zoomin.js @@ -48,7 +48,7 @@ ZoominListView.prototype.navigateTo = function(historyInfo) { var listItemWidget = this.listWidget.children[listElementIndex], targetElement = listItemWidget.findFirstDomNode(); // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { return; } // Make the new tiddler be position absolute and visible so that we can measure it @@ -130,7 +130,7 @@ function findTitleDomNode(widget,targetClass) { ZoominListView.prototype.insert = function(widget) { var targetElement = widget.findFirstDomNode(); // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { return; } // Make the newly inserted node position absolute and hidden @@ -147,7 +147,7 @@ ZoominListView.prototype.remove = function(widget) { widget.removeChildDomNodes(); }; // Abandon if the list entry isn't a DOM element (it might be a text node) - if(targetElement === undefined || targetElement.nodeType === Node.TEXT_NODE) { + if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { removeElement(); return; }