Skip to content

Commit 96528b7

Browse files
committed
Don't reuse ids when taking a full snapshot; as we are pausing mutations during snapshotting, we can continue afterwards with a freshly built DOM tree which has sequential ids according to the DOM walk (which are thus predictable and can potentially be stripped out during storage of full snapshot event)
1 parent c1c687a commit 96528b7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/snapshot.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ export function serializeNodeWithId(
465465
slimDOMOptions: SlimDOMOptions;
466466
recordCanvas?: boolean;
467467
preserveWhiteSpace?: boolean;
468+
isFullSnapshot?: boolean;
468469
},
469470
): serializedNodeWithId | null {
470471
const {
@@ -495,7 +496,7 @@ export function serializeNodeWithId(
495496

496497
let id;
497498
// Try to reuse the previous id
498-
if ('__sn' in n) {
499+
if ('__sn' in n && !isFullSnapshot) {
499500
id = n.__sn.id;
500501
} else if (
501502
slimDOMExcluded(_serializedNode, slimDOMOptions) ||
@@ -545,6 +546,7 @@ export function serializeNodeWithId(
545546
slimDOMOptions,
546547
recordCanvas,
547548
preserveWhiteSpace,
549+
isFullSnapshot,
548550
});
549551
if (serializedChildNode) {
550552
serializedNode.childNodes.push(serializedChildNode);
@@ -625,6 +627,7 @@ function snapshot(
625627
maskInputOptions,
626628
slimDOMOptions,
627629
recordCanvas,
630+
isFullSnapshot: true,
628631
}),
629632
idNodeMap,
630633
];

0 commit comments

Comments
 (0)