Skip to content

Commit 7601c37

Browse files
authored
Ensure "addEventListener" exists on "window" for "scheduler" package (#13731)
* Ensure addEventListener exists on "window"
1 parent d0c0ec9 commit 7601c37

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/scheduler/src/Scheduler.js

Lines changed: 6 additions & 1 deletion
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)