From 02f50d260cfe72209c94de1679336737f238e216 Mon Sep 17 00:00:00 2001 From: David Newell Date: Wed, 10 Apr 2024 16:46:06 +0100 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 0000000000..4e419cc2bc --- /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 81592e8170..f4267af340 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); }