Skip to content

Commit

Permalink
Fix DOMException triggered by .removeChild() in specific situations
Browse files Browse the repository at this point in the history
It can occur that a node is not a child of the parent element in some
mysterious situations such that when another add-on injects scripts into
the reviewer webview using gui_hooks.card_will_show and there is some
random whitespace in the template... Probably some kind of a race
condition.
  • Loading branch information
abdnh committed Dec 1, 2023
1 parent 769dc2f commit 53ccc21
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/template/browser/childNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ export class ChildNodeSpan {
this.parentElement.childNodes[this._fromIndex],
);
for (const node of this.span()) {
this.parentElement.removeChild(node);
if(node.parentElement === this.parentElement) {
this.parentElement.removeChild(node);
}
}

// might turn the original div into multiple nodes including text nodes
Expand Down

0 comments on commit 53ccc21

Please sign in to comment.