From 5956f9b4aaf810fafb563c542c3ca3d3aca65561 Mon Sep 17 00:00:00 2001 From: David Newell Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] protect against no parent node (#1445) * protect against a missing parent node during a mutation on an textNode --- .changeset/three-baboons-bow.md | 5 +++++ packages/rrweb/src/record/mutation.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/three-baboons-bow.md diff --git a/.changeset/three-baboons-bow.md b/.changeset/three-baboons-bow.md new file mode 100644 index 00000000..4e419cc2 --- /dev/null +++ b/.changeset/three-baboons-bow.md @@ -0,0 +1,5 @@ +--- +'rrweb': patch +--- + +fix: protect against missing parentNode diff --git a/packages/rrweb/src/record/mutation.ts b/packages/rrweb/src/record/mutation.ts index 81592e81..f4267af3 100644 --- a/packages/rrweb/src/record/mutation.ts +++ b/packages/rrweb/src/record/mutation.ts @@ -441,7 +441,10 @@ export default class MutationBuffer { texts: this.texts .map((text) => { const n = text.node; - if ((n.parentNode as Element).tagName === 'TEXTAREA') { + if ( + n.parentNode && + (n.parentNode as Element).tagName === 'TEXTAREA' + ) { // the node is being ignored as it isn't in the mirror, so shift mutation to attributes on parent textarea this.genTextAreaValueMutation(n.parentNode as HTMLTextAreaElement); }