Skip to content

Commit

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

* Ensure addEventListener exists on "window"
  • Loading branch information
trueadm authored and jetoneza committed Jan 23, 2019
1 parent f678c48 commit 928db70
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/scheduler/src/Scheduler.js
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 928db70

Please sign in to comment.