From a23653ae84aaaa5f3fbf72c6d221ec3338256110 Mon Sep 17 00:00:00 2001 From: Paulhejia <1016398426@qq.com> Date: Wed, 24 Jan 2024 15:52:44 +0800 Subject: [PATCH 1/2] fix: The needsMask check should also be ignored when the childNode array length is 0 When checking needsMask, the n.hildnode is not rigorous and the array length is greater than 0, thus ignoring the leaf component --- packages/rrweb-snapshot/src/snapshot.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/rrweb-snapshot/src/snapshot.ts b/packages/rrweb-snapshot/src/snapshot.ts index 301f84430e..549aad457f 100644 --- a/packages/rrweb-snapshot/src/snapshot.ts +++ b/packages/rrweb-snapshot/src/snapshot.ts @@ -982,7 +982,9 @@ export function serializeNodeWithId( if ( !needsMask && - n.childNodes // we can avoid the check on leaf elements, as masking is applied to child text nodes only + n.childNodes?.length > 0 + // we can avoid the check on leaf elements, as masking is applied to child text nodes only + // The needsMask check should also be ignored when the childNode array length is 0 ) { // perf: if needsMask = true, children won't also need to check const checkAncestors = needsMask === undefined; // if false, we've already checked ancestors From 1204d10449c2bf01f6f43957dd814930c321fc44 Mon Sep 17 00:00:00 2001 From: Justin Halsall Date: Fri, 2 Feb 2024 11:57:38 +0100 Subject: [PATCH 2/2] Create lazy-bananas-peel.md --- .changeset/lazy-bananas-peel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lazy-bananas-peel.md diff --git a/.changeset/lazy-bananas-peel.md b/.changeset/lazy-bananas-peel.md new file mode 100644 index 0000000000..2dd49c76db --- /dev/null +++ b/.changeset/lazy-bananas-peel.md @@ -0,0 +1,5 @@ +--- +"rrweb-snapshot": patch +--- + +fix: The needsMask check should also be ignored when the childNode array length is equal to 0