close #745, keep textarea text node clean

This commit is contained in:
Yanzhen Yu
2021-11-07 10:52:46 +08:00
parent a261f3d4de
commit 3d5b43890e
2 changed files with 31 additions and 8 deletions

View File

@@ -1428,6 +1428,21 @@ export class Replayer {
return;
}
if (
'__sn' in parent &&
parent.__sn.type === NodeType.Element &&
parent.__sn.tagName === 'textarea' &&
mutation.node.type === NodeType.Text
) {
// https://github.com/rrweb-io/rrweb/issues/745
// parent is textarea, will only keep one child node as the value
for (const c of Array.from(parent.childNodes)) {
if (c.nodeType === parent.TEXT_NODE) {
parent.removeChild(c);
}
}
}
if (previous && previous.nextSibling && previous.nextSibling.parentNode) {
parent.insertBefore(target, previous.nextSibling);
} else if (next && next.parentNode) {