diff --git a/packages/rrweb/src/record/processed-node-manager.ts b/packages/rrweb/src/record/processed-node-manager.ts index b5d6c4b679..ddff37c15b 100644 --- a/packages/rrweb/src/record/processed-node-manager.ts +++ b/packages/rrweb/src/record/processed-node-manager.ts @@ -1,4 +1,5 @@ import type MutationBuffer from './mutation'; +import { getNative } from 'rrweb-snapshot'; /** * Keeps a log of nodes that could show up in multiple mutation buffer but shouldn't be handled twice. @@ -7,13 +8,17 @@ export default class ProcessedNodeManager { private nodeMap: WeakMap> = new WeakMap(); // Whether to continue RAF loop. private loop = true; + private nativeRAF; constructor() { + this.nativeRAF = getNative( + 'requestAnimationFrame', + ).bind(window); this.periodicallyClear(); } private periodicallyClear() { - requestAnimationFrame(() => { + this.nativeRAF(() => { this.clear(); if (this.loop) this.periodicallyClear(); });