Skip to content

Commit 928db70

Browse files
trueadmjetoneza
authored andcommitted
Ensure "addEventListener" exists on "window" for "scheduler" package (facebook#13731)
* Ensure addEventListener exists on "window"
1 parent f678c48 commit 928db70

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/scheduler/src/Scheduler.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,12 @@ var requestHostCallback;
468468
var cancelHostCallback;
469469
var getFrameDeadline;
470470

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+
) {
472477
// If this accidentally gets imported in a non-browser environment, fallback
473478
// to a naive implementation.
474479
var timeoutID = -1;

0 commit comments

Comments
 (0)