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 <firstname.lastname@example.org> 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?
I'm not quite sure regarding browser consistency, e.g. the issue isn't reproduced in FF 62 (the latest release version) --
@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);
Hi, I am getting IE11 hanging and the repeated error "Assignment to read-only properties is not allowed in strict mode", on the line
in the cjs\react-dom.development.js
This is in version 16.7.0
Commenting out the line allows the site to continue working, or commenting out the
Has the build process added the 'use strict' by accident?