Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Restore global window.event after event dispatching (#13688) #13697
Details of bundled changes.
replace the code Em qui, 20 de set de 2018 às 09:30, Dan Abramov <email@example.com> escreveu:…
Can we remove the window.event assignment now? Or replace that code with this one? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#13697 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Am6hA11ebtK2kP9wA76BUyb_Z5qPu8s8ks5uc4pagaJpZM4WxKFF> .
- window.event = windowEvent; + Object.defineProperty(window, 'event', windowEventDescriptor);
After all required manipulations with fake events we have to restore the default behavior for
Object.defineProperty(window, 'event', windowEventDescriptor);
Was this helpful?
@gaearon I've used the following code to check that the fix works properly:
console.log('Global `window.event` descriptor before/after dispatching a fake event:'); console.log(Object.getOwnPropertyDescriptor(window, 'event')); ReactDOM.render( <h1>React Component</h1>, document.getElementById('container') ); console.log(Object.getOwnPropertyDescriptor(window, 'event'));
There're different results of
Here's the proof.
With the applied fix descriptors are the same:
Note: Since FF 62 and IE9-11 returns
And the issue isn't reproduced here.
I've checked the fix for the following environments:
I would appreciate if somebody could check it in iOS/Safari. Anyway I don't see why it shouldn't work here.
@sergei-startsev Looking good on iOS 12, 11, and 10 here. Unfortunately JSFiddle doesn't work on older iOS versions - but running the following script in the console works on iOS 8 and 9 as well:
var descriptor = Object.getOwnPropertyDescriptor(window, 'event'); Object.defineProperty(window, 'event', descriptor);