From 29b5b064d6742de38edebad9afd47f78639c12dc Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Thu, 6 Jul 2023 09:56:39 +0100 Subject: [PATCH] Robustify widget.removeLocalDomNodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise we get crashes if the DOM nodes generated by a widget have been subsequently modified by something like MathJax – see https://talk.tiddlywiki.org/t/tw-5-3-0-js-exception/7488/2 --- core/modules/widgets/widget.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index 0394c636f..1e6beae25 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -750,7 +750,9 @@ Widget.prototype.removeLocalDomNodes = function() { // If this widget has directly created DOM nodes, delete them and exit. if(this.domNodes.length > 0) { $tw.utils.each(this.domNodes,function(domNode) { - domNode.parentNode.removeChild(domNode); + if(domNode.parentNode) { + domNode.parentNode.removeChild(domNode); + } }); this.domNodes = []; }