File tree Expand file tree Collapse file tree 1 file changed +26
-8
lines changed Expand file tree Collapse file tree 1 file changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ var ReactTestUtils = {
274274 } ;
275275 } ,
276276
277- Simulate : { } ,
277+ Simulate : null ,
278278 SimulateNative : { }
279279} ;
280280
@@ -314,15 +314,33 @@ function makeSimulator(eventType) {
314314 } ;
315315}
316316
317- var eventType ;
318- for ( eventType in ReactEventEmitter . eventNameDispatchConfigs ) {
319- /**
320- * @param {!Element || ReactDOMComponent } domComponentOrNode
321- * @param {?object } eventData Fake event data to use in SyntheticEvent.
322- */
323- ReactTestUtils . Simulate [ eventType ] = makeSimulator ( eventType ) ;
317+ function buildSimulators ( ) {
318+ ReactTestUtils . Simulate = { } ;
319+
320+ var eventType ;
321+ for ( eventType in ReactEventEmitter . eventNameDispatchConfigs ) {
322+ /**
323+ * @param {!Element || ReactDOMComponent } domComponentOrNode
324+ * @param {?object } eventData Fake event data to use in SyntheticEvent.
325+ */
326+ ReactTestUtils . Simulate [ eventType ] = makeSimulator ( eventType ) ;
327+ }
324328}
325329
330+ // Rebuild ReactTestUtils.Simulate whenever event plugins are injected
331+ var oldInjectEventPluginOrder = EventPluginHub . injection . injectEventPluginOrder ;
332+ EventPluginHub . injection . injectEventPluginOrder = function ( ) {
333+ oldInjectEventPluginOrder . apply ( this , arguments ) ;
334+ buildSimulators ( ) ;
335+ } ;
336+ var oldInjectEventPlugins = EventPluginHub . injection . injectEventPluginsByName ;
337+ EventPluginHub . injection . injectEventPluginsByName = function ( ) {
338+ oldInjectEventPlugins . apply ( this , arguments ) ;
339+ buildSimulators ( ) ;
340+ } ;
341+
342+ buildSimulators ( ) ;
343+
326344/**
327345 * Exports:
328346 *
You can’t perform that action at this time.
0 commit comments