From ada77fe861245363ebfbe79a0805c355c35042d7 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 7 Aug 2019 23:38:09 +0800 Subject: [PATCH] remove child node before set default value --- src/rebuild.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rebuild.ts b/src/rebuild.ts index 94cc244c..7200ef81 100644 --- a/src/rebuild.ts +++ b/src/rebuild.ts @@ -106,6 +106,12 @@ function buildNode(n: serializedNodeWithId, doc: Document): Node | null { } if (isTextarea || isRemoteOrDynamicCss) { const child = doc.createTextNode(value); + // https://github.com/rrweb-io/rrweb/issues/112 + for (const c of Array.from(node.childNodes)) { + if (c.nodeType === node.TEXT_NODE) { + node.removeChild(c); + } + } node.appendChild(child); continue; }