File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,13 @@ if (__DEV__) {
98
98
// browsers that support it.
99
99
let windowEvent = window . event ;
100
100
101
+ // Keeps track of the descriptor of window.event to restore it after event
102
+ // dispatching: https://github.com/facebook/react/issues/13688
103
+ const windowEventDescriptor = Object . getOwnPropertyDescriptor (
104
+ window ,
105
+ 'event' ,
106
+ ) ;
107
+
101
108
// Create an event handler for our fake event. We will synchronously
102
109
// dispatch our fake event using `dispatchEvent`. Inside the handler, we
103
110
// call the user-provided callback.
@@ -172,6 +179,10 @@ if (__DEV__) {
172
179
evt . initEvent ( evtType , false , false ) ;
173
180
fakeNode . dispatchEvent ( evt ) ;
174
181
182
+ if ( windowEventDescriptor ) {
183
+ Object . defineProperty ( window , 'event' , windowEventDescriptor ) ;
184
+ }
185
+
175
186
if ( didError ) {
176
187
if ( ! didSetError ) {
177
188
// The callback errored, but the error event never fired.
You can’t perform that action at this time.
0 commit comments