diff --git a/src/app/app.ts b/src/app/app.ts index eebf26ed..a4e8f84d 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -25,7 +25,7 @@ export class App extends TemplateSet { Root: T; props: any; env: Env; - scheduler = new Scheduler(window.requestAnimationFrame.bind(window)); + scheduler = new Scheduler(); root: ComponentNode | null = null; constructor(Root: T, config: AppConfig = {}) { diff --git a/src/component/scheduler.ts b/src/component/scheduler.ts index 2b868d08..3a8e4be4 100644 --- a/src/component/scheduler.ts +++ b/src/component/scheduler.ts @@ -7,11 +7,14 @@ import { STATUS } from "./status"; // ----------------------------------------------------------------------------- export class Scheduler { + // capture the value of requestAnimationFrame as soon as possible, to avoid + // interactions with other code, such as test frameworks that override them + static requestAnimationFrame = window.requestAnimationFrame.bind(this); tasks: Set = new Set(); isRunning: boolean = false; requestAnimationFrame: Window["requestAnimationFrame"]; - constructor(requestAnimationFrame: Window["requestAnimationFrame"]) { + constructor() { this.requestAnimationFrame = requestAnimationFrame; }