Dynannotate: Don't crash when used in the fake DOM

Fixes #7258
This commit is contained in:
jeremy@jermolene.com 2023-02-10 09:00:52 +00:00
parent 3da3318396
commit 81f5141166
1 changed files with 23 additions and 16 deletions

View File

@ -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;