From 607f794810de5c695311177f433f0f3ba2db1cbd Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Fri, 10 Nov 2023 18:45:44 +0000 Subject: [PATCH] replaceChildNodes is not yet available in RRDom (this replacement code was extremely painful to get right from a typings point of view) --- packages/rrweb/src/replay/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/rrweb/src/replay/index.ts b/packages/rrweb/src/replay/index.ts index ab286ee441..7dafb54c09 100644 --- a/packages/rrweb/src/replay/index.ts +++ b/packages/rrweb/src/replay/index.ts @@ -1766,9 +1766,15 @@ export class Replayer { if (attributeName === 'value' && target.nodeName === 'TEXTAREA') { // this may or may not have an effect on the value property (which is what is displayed) // depending on whether the textarea has been modified by the user yet - (target as Element | RRElement).replaceChildren( - document.createTextNode(value), + // TODO: replaceChildNodes is not available in RRDom + const textarea = target as TNode; + textarea.childNodes.forEach((c) => + textarea.removeChild(c as TNode), ); + let tn = target.ownerDocument?.createTextNode(value as string); + if (tn) { + textarea.appendChild(tn as TNode); + } } else { (target as Element | RRElement).setAttribute( attributeName,