@samitouri / QOS-React-2 / commits / a447d30a2e

Rebuild simulators after injecting plugins

Ben Alpert committed Feb 18, 2014 at 23:44 UTC a447d30a2e2061964a683805c11484a8846e2349
1 file changed +26 -8
src/test/ReactTestUtils.js
+26 -8
@@ -274,7 +274,7 @@ var ReactTestUtils = {
274 };
275 },
276
277 - Simulate: {},
277 + Simulate: null,
278 SimulateNative: {}
279 };
280
@@ -314,15 +314,33 @@ function makeSimulator(eventType) {
314 };
315 }
316
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 + }
328 }
329
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 +
344 /**
345 * Exports:
346 *