-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add test cases for bugs * Fix shadow dom recording When moving an element containing shadow dom When adding an element to shadow dom before its attached to the dom * Apply formatting changes * Refactor in dom checking code * Nodes don't get processed in more than one mutation buffer * Constrain node mutations to one mutation buffer per request animation frame * Make tests less flaky under heavy load * Apply suggestions from code review * Update packages/rrweb-snapshot/test/rebuild.test.ts * Remove unused nodeSet Co-authored-by: Yun Feng <[email protected]>
- Loading branch information
1 parent
66abe17
commit 07aa1b2
Showing
11 changed files
with
831 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type MutationBuffer from './mutation'; | ||
|
||
/** | ||
* Keeps a log of nodes that could show up in multiple mutation buffer but shouldn't be handled twice. | ||
*/ | ||
export default class ProcessedNodeManager { | ||
private nodeMap: WeakMap<Node, Set<MutationBuffer>> = new WeakMap(); | ||
|
||
constructor() { | ||
this.periodicallyClear(); | ||
} | ||
|
||
private periodicallyClear() { | ||
requestAnimationFrame(() => { | ||
this.clear(); | ||
this.periodicallyClear(); | ||
}); | ||
} | ||
|
||
public inOtherBuffer(node: Node, thisBuffer: MutationBuffer) { | ||
const buffers = this.nodeMap.get(node); | ||
return ( | ||
buffers && Array.from(buffers).some((buffer) => buffer !== thisBuffer) | ||
); | ||
} | ||
|
||
public add(node: Node, buffer: MutationBuffer) { | ||
this.nodeMap.set(node, (this.nodeMap.get(node) || new Set()).add(buffer)); | ||
} | ||
|
||
private clear() { | ||
this.nodeMap = new WeakMap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.