1111
1212'use strict' ;
1313
14+ var SyntheticDragEvent = require ( 'SyntheticDragEvent' ) ;
15+
1416var caughtError = null ;
1517
1618/**
@@ -65,6 +67,11 @@ if (__DEV__) {
6567 typeof document . createEvent === 'function' ) {
6668 var fakeNode = document . createElement ( 'react' ) ;
6769 ReactErrorUtils . invokeGuardedCallback = function ( name , func , a , b ) {
70+ if ( ! canWrapEvent ( a ) ) {
71+ invokeGuardedCallback ( name , func , a , b ) ;
72+ return ;
73+ }
74+
6875 var boundFunc = func . bind ( null , a , b ) ;
6976 var evtType = `react-${ name } ` ;
7077 fakeNode . addEventListener ( evtType , boundFunc , false ) ;
@@ -74,6 +81,41 @@ if (__DEV__) {
7481 fakeNode . removeEventListener ( evtType , boundFunc , false ) ;
7582 } ;
7683 }
84+
85+ var cacheCanWrapEvent = null ;
86+
87+ /**
88+ * IE and Edge don't allow access to the DataTransfer.dropEffect property when
89+ * it's wrapped in another event. This function detects whether we're in an
90+ * environment that behaves this way.
91+ *
92+ * @param {* } ev Event that is being tested
93+ */
94+ function canWrapEvent ( ev ) {
95+ if ( ! ( ev instanceof SyntheticDragEvent ) ) {
96+ return true ;
97+ } else if ( cacheCanWrapEvent !== null ) {
98+ return cacheCanWrapEvent ;
99+ }
100+
101+ var canAccessDropEffect = false ;
102+ function handleWrappedEvent ( ) {
103+ try {
104+ ev . dataTransfer . dropEffect ; // eslint-disable-line no-unused-expressions
105+ canAccessDropEffect = true ;
106+ } catch ( e ) { }
107+ }
108+
109+ var wrappedEventName = 'react-wrappeddragevent' ;
110+ var wrappedEvent = document . createEvent ( 'Event' ) ;
111+ wrappedEvent . initEvent ( wrappedEventName , false , false ) ;
112+ fakeNode . addEventListener ( wrappedEventName , handleWrappedEvent , false ) ;
113+ fakeNode . dispatchEvent ( wrappedEvent ) ;
114+ fakeNode . removeEventListener ( wrappedEventName , handleWrappedEvent , false ) ;
115+
116+ cacheCanWrapEvent = canAccessDropEffect ;
117+ return canAccessDropEffect ;
118+ }
77119}
78120
79121module . exports = ReactErrorUtils ;
0 commit comments