fix #531 use getRootNode with precheck

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 83045059f9
commit 3e8cacbb95

View File

@@ -247,7 +247,9 @@ export default class MutationBuffer {
return nextId; return nextId;
}; };
const pushAdd = (n: Node) => { const pushAdd = (n: Node) => {
const shadowHost: Element | null = (n.getRootNode() as ShadowRoot)?.host; const shadowHost: Element | null = n.getRootNode
? (n.getRootNode() as ShadowRoot)?.host
: null;
const notInDoc = !this.doc.contains(n) && !this.doc.contains(shadowHost); const notInDoc = !this.doc.contains(n) && !this.doc.contains(shadowHost);
if (!n.parentNode || notInDoc) { if (!n.parentNode || notInDoc) {
return; return;