mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #5157 from spicyj/createevent
Use 'document.createEvent' not 'new Event'
This commit is contained in:
commit
194ab16d7b
1 file changed
+4
-3
@@ -61,13 +61,14 @@ if (__DEV__) {
|
||||
* real browser event.
|
||||
*/
|
||||
if (typeof window !== 'undefined' &&
|
||||
typeof window.dispatchEvent === 'function' &&
|
||||
typeof Event === 'function') {
|
||||
typeof window.dispatchEvent === 'function') {
|
||||
var fakeNode = document.createElement('react');
|
||||
ReactErrorUtils.invokeGuardedCallback = function(name, func, a, b) {
|
||||
var boundFunc = func.bind(null, a, b);
|
||||
fakeNode.addEventListener(name, boundFunc, false);
|
||||
fakeNode.dispatchEvent(new Event(name));
|
||||
var evt = document.createEvent('Event');
|
||||
evt.initEvent(name, false, false);
|
||||
fakeNode.dispatchEvent(evt);
|
||||
fakeNode.removeEventListener(name, boundFunc, false);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user