protect against no parent node (#1445)

* protect against a missing parent node during a mutation on an textNode
This commit is contained in:
David Newell
2024-04-10 16:46:06 +01:00
committed by GitHub
parent 3d1877cff8
commit 02f50d260c
2 changed files with 9 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'rrweb': patch
---
fix: protect against missing parentNode

View File

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