Skip to content

Commit

Permalink
replaceChildNodes is not yet available in RRDom (this replacement cod…
Browse files Browse the repository at this point in the history
…e was extremely painful to get right from a typings point of view)
  • Loading branch information
eoghanmurray committed Nov 10, 2023
1 parent 162f9f3 commit 607f794
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 607f794

Please sign in to comment.