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); }