Ensure "addEventListener" exists on "window" for "scheduler" package #13731
Conversation
I think it would be more consistent to do this in the existing |
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 |
@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.