Skip to content

Commit

Permalink
Ensure "addEventListener" exists on "window" for "scheduler" package (#…
Browse files Browse the repository at this point in the history
…13731)

* Ensure addEventListener exists on "window"
  • Loading branch information
trueadm authored Sep 26, 2018
1 parent d0c0ec9 commit 7601c37
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/scheduler/src/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,12 @@ var requestHostCallback;
var cancelHostCallback;
var getFrameDeadline;

if (typeof window === 'undefined') {
// "addEventListener" might not be available on the window object
// if this is a mocked "window" object. So we need to validate that too.
if (
typeof window === 'undefined' ||
typeof window.addEventListener !== 'function'
) {
// If this accidentally gets imported in a non-browser environment, fallback
// to a naive implementation.
var timeoutID = -1;
Expand Down

0 comments on commit 7601c37

Please sign in to comment.