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

* Ensure addEventListener exists on "window"
This commit is contained in:
Dominic Gannaway
2018-09-26 13:38:56 +01:00
committed by GitHub
parent d0c0ec98ef
commit 7601c37654
+6 -1
View File
@@ -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;