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 6b6d76c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 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 All @@ -477,6 +478,7 @@ export function serializeNodeWithId(
maskInputOptions = {},
slimDOMOptions,
recordCanvas = false,
isFullSnapshot = false,
} = options;
let { preserveWhiteSpace = true } = options;
const _serializedNode = serializeNode(n, {
Expand All @@ -495,7 +497,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 +547,7 @@ export function serializeNodeWithId(
slimDOMOptions,
recordCanvas,
preserveWhiteSpace,
isFullSnapshot,
});
if (serializedChildNode) {
serializedNode.childNodes.push(serializedChildNode);
Expand Down Expand Up @@ -625,6 +628,7 @@ function snapshot(
maskInputOptions,
slimDOMOptions,
recordCanvas,
isFullSnapshot: true,
}),
idNodeMap,
];
Expand Down

0 comments on commit 6b6d76c

Please sign in to comment.