Skip to content

Commit

Permalink
fix(timetravel): push dom changes one at a time
Browse files Browse the repository at this point in the history
CLOSES #252
  • Loading branch information
blakebyrnes committed Mar 11, 2024
1 parent abc4fbf commit b179075
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion timetravel/injected-scripts/domReplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ class DomReplayer {
}

private applyDomChanges(changeEvents: IFrontendDomChangeEvent[], isReverse = false): void {
this.pendingDomChanges.push(...changeEvents);
for (const change of changeEvents) {
this.pendingDomChanges.push(change);
}
if (document.readyState !== 'complete') {
document.addEventListener('DOMContentLoaded', () => this.applyDomChanges([]), { once: true });
return;
Expand Down
8 changes: 6 additions & 2 deletions timetravel/lib/MirrorPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ export default class MirrorPage extends TypedEventEmitter<{
this.domRecording.paintEvents.push(paint);
this.paintEventByTimestamp[paint.timestamp] = paint;
} else {
existing.changeEvents.push(...paint.changeEvents);
for (const change of paint.changeEvents) {
existing.changeEvents.push(change);
}
existing.changeEvents.sort((a, b) => {
if (a.frameId === b.frameId) return a.eventIndex - b.eventIndex;
return a.frameId - b.frameId;
Expand All @@ -458,7 +460,9 @@ export default class MirrorPage extends TypedEventEmitter<{

private onPageEvents(event: ITabEventParams['page-events']): void {
const { domChanges } = event.records;
this.pendingDomChanges.push(...domChanges);
for (const record of domChanges) {
this.pendingDomChanges.push(record);
}
}

private async evaluate<T>(expression: string): Promise<T> {
Expand Down

0 comments on commit b179075

Please sign in to comment.