@samitouri / QOS-React-2 / commits / 7601c37654

Ensure "addEventListener" exists on "window" for "scheduler" package (#13731)

* Ensure addEventListener exists on "window"

Dominic Gannaway committed Sep 26, 2018 at 13:38 UTC 7601c3765457a4ec7b2d48c0ca75fccf7fecf917
1 file changed +6 -1
packages/scheduler/src/Scheduler.js
+6 -1
@@ -468,7 +468,12 @@ var requestHostCallback;
468 var cancelHostCallback;
469 var getFrameDeadline;
470
471 -if (typeof window === 'undefined') {
471 +// "addEventListener" might not be available on the window object
472 +// if this is a mocked "window" object. So we need to validate that too.
473 +if (
474 + typeof window === 'undefined' ||
475 + typeof window.addEventListener !== 'function'
476 +) {
477 // If this accidentally gets imported in a non-browser environment, fallback
478 // to a naive implementation.
479 var timeoutID = -1;