Use 'document.createEvent' not 'new Event'
Fixes #5153. This seems to work in all browsers I tested, including old Android and all IE > 8 which didn't work before.
Ben Alpert committed
Oct 13, 2015 at 11:11 UTC
6488a4c1872192b2282b68ceabc20645662b9121
1 file changed
+4
-3
src/shared/utils/ReactErrorUtils.js
+4
-3
@@ -61,13 +61,14 @@ if (__DEV__) {
61
* real browser event.
62
*/
63
if (typeof window !== 'undefined' &&
64
- typeof window.dispatchEvent === 'function' &&
65
- typeof Event === 'function') {
64
+ typeof window.dispatchEvent === 'function') {
65
var fakeNode = document.createElement('react');
66
ReactErrorUtils.invokeGuardedCallback = function(name, func, a, b) {
67
var boundFunc = func.bind(null, a, b);
68
fakeNode.addEventListener(name, boundFunc, false);
70
- fakeNode.dispatchEvent(new Event(name));
69
+ var evt = document.createEvent('Event');
70
+ evt.initEvent(name, false, false);
71
+ fakeNode.dispatchEvent(evt);
72
fakeNode.removeEventListener(name, boundFunc, false);
73
};
74
}