Skip to content

Commit

Permalink
Avoid calls to el.matches when on a leaf node, e.g. a <br/>
Browse files Browse the repository at this point in the history
  • Loading branch information
eoghanmurray committed Nov 15, 2023
1 parent d19e922 commit 1b37e33
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,9 @@ export function serializeNodeWithId(
let { needsMask } = options;
let { preserveWhiteSpace = true } = options;

if (!needsMask) {
if (!needsMask &&
n.childNodes // we can avoid the check on leaf elements, as masking is applied to child text nodes only
) {
// perf: if needsMask = true, children won't also need to check
const checkAncestors = needsMask === undefined; // if false, we've already checked ancestors
needsMask = needMaskingText(
Expand Down

0 comments on commit 1b37e33

Please sign in to comment.