From 0e90b0eeaa21e8996ed65c042bf1ee8c129323f8 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Fri, 17 Feb 2023 17:54:16 +0000 Subject: [PATCH 1/3] Extend the suppression of warnings to take account that a prior removal may not have been against the immediate parent of a subsequent removal, but rather some anscestor --- packages/rrweb/src/replay/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/rrweb/src/replay/index.ts b/packages/rrweb/src/replay/index.ts index a6591142c0..01f1d6e0d9 100644 --- a/packages/rrweb/src/replay/index.ts +++ b/packages/rrweb/src/replay/index.ts @@ -1361,14 +1361,20 @@ export class Replayer { const mirror = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror; type TNode = typeof mirror extends Mirror ? Node : RRNode; + d.removes = d.removes.filter((mutation) => { + // warn of absence from mirror before we start applying each removal + // as earlier removals could remove a tree that includes a later removal + if (!mirror.getNode(mutation.id)) { + this.warnNodeNotFound(d, mutation.id); + return false; + } + return true; + }); d.removes.forEach((mutation) => { const target = mirror.getNode(mutation.id); if (!target) { - if (d.removes.find((r) => r.id === mutation.parentId)) { - // no need to warn, parent was already removed - return; - } - return this.warnNodeNotFound(d, mutation.id); + // no need to warn here, an ancestor may have already been removed + return; } let parent: Node | null | ShadowRoot | RRNode = mirror.getNode( mutation.parentId, From 6ba90fe93caf5e1b2d5a3d35576b1dcf3313f1e7 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Fri, 3 Mar 2023 11:13:07 +0000 Subject: [PATCH 2/3] Create proud-experts-jam.md --- .changeset/proud-experts-jam.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/proud-experts-jam.md diff --git a/.changeset/proud-experts-jam.md b/.changeset/proud-experts-jam.md new file mode 100644 index 0000000000..52d41254c8 --- /dev/null +++ b/.changeset/proud-experts-jam.md @@ -0,0 +1,5 @@ +--- +"rrweb": patch +--- + +For a mutation which removes a node, reduce the number of spurious warnings to take into account that an anscestor (rather than just a parent) may have been just removed From e6c7a251ea78243a0ac7725d2bc3d309f54466f1 Mon Sep 17 00:00:00 2001 From: eoghanmurray Date: Fri, 3 Mar 2023 11:14:36 +0000 Subject: [PATCH 3/3] Apply formatting changes --- .changeset/proud-experts-jam.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/proud-experts-jam.md b/.changeset/proud-experts-jam.md index 52d41254c8..fa60839bb9 100644 --- a/.changeset/proud-experts-jam.md +++ b/.changeset/proud-experts-jam.md @@ -1,5 +1,5 @@ --- -"rrweb": patch +'rrweb': patch --- For a mutation which removes a node, reduce the number of spurious warnings to take into account that an anscestor (rather than just a parent) may have been just removed