From c7966070ef9584bbaa95d71c5590aa4e83bab5dd Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] fix https://github.com/rrweb-io/rrweb/issues/395 --- src/snapshot.ts | 7 +++++-- test/__snapshots__/integration.ts.snap | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/snapshot.ts b/src/snapshot.ts index 4c17612f..81d8e83f 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -309,8 +309,11 @@ function serializeNode( } if (needBlock) { const { width, height } = (n as HTMLElement).getBoundingClientRect(); - attributes.rr_width = `${width}px`; - attributes.rr_height = `${height}px`; + attributes = { + class: attributes.class, + rr_width: `${width}px`, + rr_height: `${height}px`, + }; } return { type: NodeType.Element, diff --git a/test/__snapshots__/integration.ts.snap b/test/__snapshots__/integration.ts.snap index f5c84e18..43bb79cd 100644 --- a/test/__snapshots__/integration.ts.snap +++ b/test/__snapshots__/integration.ts.snap @@ -70,7 +70,7 @@ exports[`[html file]: block-element.html 1`] = `
record 2
-
+
" `;