From 81f514116657d0d567be7a4c45762a85beaa8bc0 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Fri, 10 Feb 2023 09:00:52 +0000 Subject: [PATCH] Dynannotate: Don't crash when used in the fake DOM Fixes #7258 --- .../dynannotate/modules/dynannotate.js | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/plugins/tiddlywiki/dynannotate/modules/dynannotate.js b/plugins/tiddlywiki/dynannotate/modules/dynannotate.js index cd47c07c7..12d8f7155 100644 --- a/plugins/tiddlywiki/dynannotate/modules/dynannotate.js +++ b/plugins/tiddlywiki/dynannotate/modules/dynannotate.js @@ -38,23 +38,28 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) { // Create our DOM nodes var isSnippetMode = this.isSnippetMode(); this.domContent = $tw.utils.domMaker("div",{ - "class": "tc-dynannotation-selection-container" + "class": "tc-dynannotation-selection-container", + document: this.document }); if(isSnippetMode) { - this.domContent.setAttribute("hidden","hidden"); + this.domContent.setAttribute("hidden","hidden"); } this.domAnnotations = $tw.utils.domMaker("div",{ - "class": "tc-dynannotation-annotation-wrapper" + "class": "tc-dynannotation-annotation-wrapper", + document: this.document }); this.domSnippets = $tw.utils.domMaker("div",{ - "class": "tc-dynannotation-snippet-wrapper" + "class": "tc-dynannotation-snippet-wrapper", + document: this.document }); this.domSearches = $tw.utils.domMaker("div",{ - "class": "tc-dynannotation-search-wrapper" + "class": "tc-dynannotation-search-wrapper", + document: this.document }); this.domWrapper = $tw.utils.domMaker("div",{ "class": "tc-dynannotation-wrapper", - children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches] + children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches], + document: this.document }) parent.insertBefore(this.domWrapper,nextSibling); this.domNodes.push(this.domWrapper); @@ -64,16 +69,18 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) { } // Render our child widgets this.renderChildren(this.domContent,null); - if(isSnippetMode) { - // Apply search snippets - this.applySnippets(); - } else { - // Get the list of annotation tiddlers - this.getAnnotationTiddlers(); - // Apply annotations - this.applyAnnotations(); - // Apply search overlays - this.applySearch(); + if(!this.document.isTiddlyWikiFakeDom) { + if(isSnippetMode) { + // Apply search snippets + this.applySnippets(); + } else { + // Get the list of annotation tiddlers + this.getAnnotationTiddlers(); + // Apply annotations + this.applyAnnotations(); + // Apply search overlays + this.applySearch(); + } } // Save the width of the wrapper so that we can tell when it changes this.wrapperWidth = this.domWrapper.offsetWidth;