Skip to content

Commit

Permalink
Fix mutation edge case when blocked class gets unblocked (#867)
Browse files Browse the repository at this point in the history
* Fix mutation edge case when blocked class gets unblocked

* Add integration test

* Update isSerialized logic
  • Loading branch information
rahulrelicx authored Apr 15, 2022
1 parent e4f680e commit 93fec1f
Show file tree
Hide file tree
Showing 5 changed files with 854 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
isBlocked,
isAncestorRemoved,
isIgnored,
isSerialized,
hasShadowRoot,
isSerializedIframe,
} from '../utils';
Expand Down Expand Up @@ -525,7 +526,8 @@ export default class MutationBuffer {
: this.mirror.getId(m.target);
if (
isBlocked(m.target, this.blockClass) ||
isIgnored(n, this.mirror)
isIgnored(n, this.mirror) ||
!isSerialized(n, this.mirror)
) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/rrweb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ export function isBlocked(node: Node | null, blockClass: blockClass): boolean {
return isBlocked(node.parentNode, blockClass);
}

export function isSerialized(n: Node, mirror: Mirror): boolean {
return mirror.getId(n) !== -1;
}

export function isIgnored(n: Node, mirror: Mirror): boolean {
// The main part of the slimDOM check happens in
// rrweb-snapshot::serializeNodeWithId
Expand Down
Loading

0 comments on commit 93fec1f

Please sign in to comment.