-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure "addEventListener" exists on "window" for "scheduler" package #13731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more consistent to do this in the existing typeof window === 'undefined'
check.
It would also be nice to get an understanding of what changed that made this a problem for RN. |
@gaearon Why would you do it in the |
I mean that for our purposes “window without addEventListener” is just as bad as “undefined window”. So we should treat them the same way — by falling back. |
This is what I’d like to clarify. It’s not clear to me how it got pulled in. Do we know where it’s imported? |
Details of bundled changes.Comparing: d0c0ec9...c35bf9f scheduler
Generated by 🚫 dangerJS |
@gaearon I understand what you mean now, thanks for clarifying. So my primary fix for this was to remove the |
Ah. This makes sense. |
…acebook#13731) * Ensure addEventListener exists on "window"
…acebook#13731) * Ensure addEventListener exists on "window"
I think this issue has resurface itself in react-dom@16.13.1 which pulls scheduler@0.19.1 |
This fixes #13694.
When the scheduler package initializes, it tries to attach an event listener to
window
viaaddEventListener
. In some environments, thewindow
object might be mocked and thusaddEventListener
might be missing. This PR adds a check to ensure that this function does exist before trying to attach the event.