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__) {
9898 // browsers that support it.
9999 let windowEvent = window . event ;
100100
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+
101108 // Create an event handler for our fake event. We will synchronously
102109 // dispatch our fake event using `dispatchEvent`. Inside the handler, we
103110 // call the user-provided callback.
@@ -172,6 +179,10 @@ if (__DEV__) {
172179 evt . initEvent ( evtType , false , false ) ;
173180 fakeNode . dispatchEvent ( evt ) ;
174181
182+ if ( windowEventDescriptor ) {
183+ Object . defineProperty ( window , 'event' , windowEventDescriptor ) ;
184+ }
185+
175186 if ( didError ) {
176187 if ( ! didSetError ) {
177188 // The callback errored, but the error event never fired.
You can’t perform that action at this time.
0 commit comments