Skip to content

Commit

Permalink
Don't reuse ids when taking a full snapshot; as we are pausing mutati…
Browse files Browse the repository at this point in the history
…ons 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)
  • Loading branch information
eoghanmurray committed Jan 29, 2021
1 parent c1c687a commit 96528b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ export function serializeNodeWithId(
slimDOMOptions: SlimDOMOptions;
recordCanvas?: boolean;
preserveWhiteSpace?: boolean;
isFullSnapshot?: boolean;
},
): serializedNodeWithId | null {
const {
Expand Down Expand Up @@ -495,7 +496,7 @@ export function serializeNodeWithId(

let id;
// Try to reuse the previous id
if ('__sn' in n) {
if ('__sn' in n && !isFullSnapshot) {
id = n.__sn.id;
} else if (
slimDOMExcluded(_serializedNode, slimDOMOptions) ||
Expand Down Expand Up @@ -545,6 +546,7 @@ export function serializeNodeWithId(
slimDOMOptions,
recordCanvas,
preserveWhiteSpace,
isFullSnapshot,
});
if (serializedChildNode) {
serializedNode.childNodes.push(serializedChildNode);
Expand Down Expand Up @@ -625,6 +627,7 @@ function snapshot(
maskInputOptions,
slimDOMOptions,
recordCanvas,
isFullSnapshot: true,
}),
idNodeMap,
];
Expand Down

0 comments on commit 96528b7

Please sign in to comment.