1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 17:10:29 +00:00

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

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.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,6 +69,7 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
}
// Render our child widgets
this.renderChildren(this.domContent,null);
if(!this.document.isTiddlyWikiFakeDom) {
if(isSnippetMode) {
// Apply search snippets
this.applySnippets();
@ -75,6 +81,7 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
// Apply search overlays
this.applySearch();
}
}
// Save the width of the wrapper so that we can tell when it changes
this.wrapperWidth = this.domWrapper.offsetWidth;
};