From 595d90e8c0b6a009ec29d43752bd635b4b4a3e9f Mon Sep 17 00:00:00 2001 From: wangfukang Date: Thu, 8 Sep 2022 19:47:26 +0800 Subject: [PATCH 1/2] fix: add mutation lost in slimDOMOptions --- packages/rrweb/src/record/mutation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rrweb/src/record/mutation.ts b/packages/rrweb/src/record/mutation.ts index df3b3017c2..d11b53a172 100644 --- a/packages/rrweb/src/record/mutation.ts +++ b/packages/rrweb/src/record/mutation.ts @@ -257,7 +257,7 @@ export default class MutationBuffer { const getNextId = (n: Node): number | null => { let ns: Node | null = n; let nextId: number | null = IGNORED_NODE; // slimDOM: ignored - while (nextId === IGNORED_NODE) { + while (nextId === IGNORED_NODE || nextId === -1) { ns = ns && ns.nextSibling; nextId = ns && this.mirror.getId(ns); } From 243a80a088c0e254aee636e9c6b0049345d0d4cf Mon Sep 17 00:00:00 2001 From: wangfukang Date: Fri, 9 Sep 2022 13:22:01 +0800 Subject: [PATCH 2/2] fix: slimDOMOptions-mutation-lost --- packages/rrweb-snapshot/src/snapshot.ts | 9 +++++---- packages/rrweb/src/record/mutation.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/rrweb-snapshot/src/snapshot.ts b/packages/rrweb-snapshot/src/snapshot.ts index 38df3b6954..277f6e5951 100644 --- a/packages/rrweb-snapshot/src/snapshot.ts +++ b/packages/rrweb-snapshot/src/snapshot.ts @@ -1014,14 +1014,15 @@ export function serializeNodeWithId( } else { id = genId(); } - if (id === IGNORED_NODE) { - return null; // slimDOM - } const serializedNode = Object.assign(_serializedNode, { id }); - + // add IGNORED_NODE to mirror to track nextSiblings mirror.add(n, serializedNode); + if (id === IGNORED_NODE) { + return null; // slimDOM + } + if (onSerialize) { onSerialize(n); } diff --git a/packages/rrweb/src/record/mutation.ts b/packages/rrweb/src/record/mutation.ts index d11b53a172..df3b3017c2 100644 --- a/packages/rrweb/src/record/mutation.ts +++ b/packages/rrweb/src/record/mutation.ts @@ -257,7 +257,7 @@ export default class MutationBuffer { const getNextId = (n: Node): number | null => { let ns: Node | null = n; let nextId: number | null = IGNORED_NODE; // slimDOM: ignored - while (nextId === IGNORED_NODE || nextId === -1) { + while (nextId === IGNORED_NODE) { ns = ns && ns.nextSibling; nextId = ns && this.mirror.getId(ns); }