From 3e8cacbb956df1a30b05f0b5f8225d9eee11620f Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] fix #531 use getRootNode with precheck --- src/record/mutation.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/record/mutation.ts b/src/record/mutation.ts index f1f2aa86..3717afc8 100644 --- a/src/record/mutation.ts +++ b/src/record/mutation.ts @@ -247,7 +247,9 @@ export default class MutationBuffer { return nextId; }; 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); if (!n.parentNode || notInDoc) { return;