Skip to content

Commit 02f50d2

Browse files
authored
protect against no parent node (#1445)
* protect against a missing parent node during a mutation on an textNode
1 parent 3d1877c commit 02f50d2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/three-baboons-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'rrweb': patch
3+
---
4+
5+
fix: protect against missing parentNode

packages/rrweb/src/record/mutation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,10 @@ export default class MutationBuffer {
441441
texts: this.texts
442442
.map((text) => {
443443
const n = text.node;
444-
if ((n.parentNode as Element).tagName === 'TEXTAREA') {
444+
if (
445+
n.parentNode &&
446+
(n.parentNode as Element).tagName === 'TEXTAREA'
447+
) {
445448
// the node is being ignored as it isn't in the mirror, so shift mutation to attributes on parent textarea
446449
this.genTextAreaValueMutation(n.parentNode as HTMLTextAreaElement);
447450
}

0 commit comments

Comments
 (0)