Skip to content

Commit

Permalink
traverse children in reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellanoce committed Jan 16, 2024
1 parent 07ac5c9 commit 4974b45
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,15 @@ export default class MutationBuffer {
// if this node is blocked `serializeNode` will turn it into a placeholder element
// but we have to remove it's children otherwise they will be added as placeholders too
if (!isBlocked(n, this.blockClass, this.blockSelector, false)) {
n.childNodes.forEach((childN) => this.genAdds(childN));
for (let i = n.childNodes.length - 1; i >= 0; --i) {
this.genAdds(n.childNodes[i]);
}
if (hasShadowRoot(n)) {
n.shadowRoot.childNodes.forEach((childN) => {
for (let j = n.shadowRoot.childNodes.length - 1; j >= 0; --j) {
let childN = n.shadowRoot.childNodes[j];
this.processedNodeManager.add(childN, this);
this.genAdds(childN, n);
});
}
}
}
};
Expand Down

0 comments on commit 4974b45

Please sign in to comment.