react 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +0 -8
  2. package/addons.js +0 -3
  3. package/lib/AutoFocusMixin.js +32 -0
  4. package/lib/CSSCore.js +23 -22
  5. package/lib/CSSProperty.js +32 -1
  6. package/lib/CSSPropertyOperations.js +1 -1
  7. package/lib/ChangeEventPlugin.js +27 -5
  8. package/lib/ClientReactRootIndex.js +30 -0
  9. package/lib/CompositionEventPlugin.js +58 -10
  10. package/lib/DOMChildrenOperations.js +39 -3
  11. package/lib/DOMProperty.js +9 -5
  12. package/lib/DOMPropertyOperations.js +21 -8
  13. package/lib/Danger.js +9 -8
  14. package/lib/DefaultDOMPropertyConfig.js +23 -14
  15. package/lib/DefaultEventPluginOrder.js +1 -1
  16. package/lib/EnterLeaveEventPlugin.js +38 -5
  17. package/lib/EventConstants.js +4 -1
  18. package/lib/EventListener.js +42 -34
  19. package/lib/EventPluginHub.js +118 -13
  20. package/lib/EventPluginRegistry.js +62 -18
  21. package/lib/EventPluginUtils.js +33 -4
  22. package/lib/EventPropagators.js +7 -43
  23. package/lib/ExecutionEnvironment.js +4 -1
  24. package/lib/LinkedStateMixin.js +1 -1
  25. package/lib/LinkedValueUtils.js +160 -0
  26. package/lib/MobileSafariClickEventPlugin.js +1 -1
  27. package/lib/PooledClass.js +7 -1
  28. package/lib/React.js +30 -4
  29. package/lib/ReactBrowserComponentMixin.js +42 -0
  30. package/lib/ReactCSSTransitionGroup.js +65 -0
  31. package/lib/{ReactTransitionableChild.js → ReactCSSTransitionGroupChild.js} +22 -36
  32. package/lib/ReactChildren.js +4 -4
  33. package/lib/ReactComponent.js +163 -83
  34. package/lib/ReactComponentBrowserEnvironment.js +55 -71
  35. package/lib/ReactCompositeComponent.js +686 -119
  36. package/lib/ReactContext.js +67 -0
  37. package/lib/ReactCurrentOwner.js +1 -1
  38. package/lib/ReactDOM.js +19 -6
  39. package/lib/ReactDOMButton.js +6 -1
  40. package/lib/ReactDOMComponent.js +66 -24
  41. package/lib/ReactDOMForm.js +13 -3
  42. package/lib/ReactDOMIDOperations.js +106 -61
  43. package/lib/ReactDOMImg.js +61 -0
  44. package/lib/ReactDOMInput.js +28 -15
  45. package/lib/ReactDOMOption.js +13 -8
  46. package/lib/ReactDOMSelect.js +38 -18
  47. package/lib/ReactDOMSelection.js +1 -1
  48. package/lib/ReactDOMTextarea.js +19 -11
  49. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  50. package/lib/ReactDefaultInjection.js +60 -26
  51. package/lib/ReactDefaultPerf.js +208 -371
  52. package/lib/ReactDefaultPerfAnalysis.js +199 -0
  53. package/lib/ReactErrorUtils.js +6 -15
  54. package/lib/ReactEventEmitter.js +144 -146
  55. package/lib/ReactEventEmitterMixin.js +1 -33
  56. package/lib/ReactEventTopLevelCallback.js +75 -15
  57. package/lib/ReactInjection.js +43 -0
  58. package/lib/ReactInputSelection.js +3 -2
  59. package/lib/ReactInstanceHandles.js +36 -20
  60. package/lib/ReactLink.js +2 -2
  61. package/lib/ReactMarkupChecksum.js +1 -1
  62. package/lib/ReactMount.js +136 -104
  63. package/lib/ReactMountReady.js +2 -2
  64. package/lib/ReactMultiChild.js +40 -49
  65. package/lib/ReactMultiChildUpdateTypes.js +3 -1
  66. package/lib/ReactOwner.js +17 -4
  67. package/lib/ReactPerf.js +6 -9
  68. package/lib/ReactPropTransferer.js +41 -22
  69. package/lib/ReactPropTypeLocationNames.js +31 -0
  70. package/lib/{ReactComponentEnvironment.js → ReactPropTypeLocations.js} +11 -6
  71. package/lib/ReactPropTypes.js +249 -48
  72. package/lib/ReactPutListenerQueue.js +61 -0
  73. package/lib/ReactReconcileTransaction.js +28 -7
  74. package/lib/ReactRootIndex.js +36 -0
  75. package/lib/ReactServerRendering.js +46 -19
  76. package/lib/ReactServerRenderingTransaction.js +116 -0
  77. package/lib/ReactStateSetters.js +1 -1
  78. package/lib/ReactTestUtils.js +394 -0
  79. package/lib/ReactTextComponent.js +33 -6
  80. package/lib/{ReactTransitionKeySet.js → ReactTransitionChildMapping.js} +43 -48
  81. package/lib/ReactTransitionEvents.js +1 -1
  82. package/lib/ReactTransitionGroup.js +133 -58
  83. package/lib/ReactUpdates.js +15 -12
  84. package/lib/ReactWithAddons.js +15 -3
  85. package/lib/SelectEventPlugin.js +23 -40
  86. package/lib/ServerReactRootIndex.js +36 -0
  87. package/lib/SimpleEventPlugin.js +55 -7
  88. package/lib/SyntheticClipboardEvent.js +8 -2
  89. package/lib/SyntheticCompositionEvent.js +1 -1
  90. package/lib/SyntheticDragEvent.js +44 -0
  91. package/lib/SyntheticEvent.js +3 -2
  92. package/lib/SyntheticFocusEvent.js +1 -1
  93. package/lib/SyntheticKeyboardEvent.js +5 -3
  94. package/lib/SyntheticMouseEvent.js +1 -1
  95. package/lib/SyntheticTouchEvent.js +1 -1
  96. package/lib/SyntheticUIEvent.js +1 -1
  97. package/lib/SyntheticWheelEvent.js +11 -8
  98. package/lib/Transaction.js +62 -37
  99. package/lib/ViewportMetrics.js +1 -1
  100. package/lib/accumulate.js +1 -1
  101. package/lib/adler32.js +1 -1
  102. package/lib/cloneWithProps.js +59 -0
  103. package/lib/containsNode.js +1 -1
  104. package/lib/copyProperties.js +1 -1
  105. package/lib/createArrayFrom.js +11 -14
  106. package/lib/createFullPageComponent.js +63 -0
  107. package/lib/createNodesFromMarkup.js +1 -1
  108. package/lib/createObjectFrom.js +1 -1
  109. package/lib/cx.js +3 -3
  110. package/lib/dangerousStyleValue.js +1 -1
  111. package/lib/emptyFunction.js +1 -1
  112. package/lib/emptyObject.js +27 -0
  113. package/lib/escapeTextForBrowser.js +1 -1
  114. package/lib/flattenChildren.js +6 -3
  115. package/lib/focusNode.js +33 -0
  116. package/lib/forEachAccumulated.js +1 -1
  117. package/lib/getActiveElement.js +5 -4
  118. package/lib/getEventKey.js +85 -0
  119. package/lib/getEventTarget.js +1 -1
  120. package/lib/getMarkupWrap.js +11 -1
  121. package/lib/getNodeForCharacterOffset.js +1 -1
  122. package/lib/getReactRootElementInContainer.js +1 -1
  123. package/lib/getTextContentAccessor.js +6 -4
  124. package/lib/getUnboundedScrollPosition.js +3 -3
  125. package/lib/hyphenate.js +1 -1
  126. package/lib/instantiateReactComponent.js +70 -0
  127. package/lib/invariant.js +20 -12
  128. package/lib/isEventSupported.js +8 -12
  129. package/lib/isNode.js +2 -2
  130. package/lib/isTextInputElement.js +1 -1
  131. package/lib/isTextNode.js +1 -1
  132. package/lib/joinClasses.js +1 -1
  133. package/lib/keyMirror.js +1 -1
  134. package/lib/keyOf.js +1 -1
  135. package/lib/memoizeStringOnly.js +1 -1
  136. package/lib/merge.js +1 -1
  137. package/lib/mergeHelpers.js +6 -7
  138. package/lib/mergeInto.js +1 -1
  139. package/lib/mixInto.js +1 -1
  140. package/lib/monitorCodeUse.js +37 -0
  141. package/lib/objMap.js +1 -1
  142. package/lib/objMapKeyVal.js +1 -1
  143. package/lib/onlyChild.js +43 -0
  144. package/lib/performanceNow.js +1 -1
  145. package/lib/shallowEqual.js +1 -1
  146. package/lib/shouldUpdateReactComponent.js +61 -0
  147. package/lib/toArray.js +75 -0
  148. package/lib/traverseAllChildren.js +72 -9
  149. package/lib/update.js +159 -0
  150. package/lib/warning.js +48 -0
  151. package/package.json +3 -3
  152. package/react.js +0 -3
  153. package/ReactJSErrors.js +0 -40
  154. package/lib/$.js +0 -46
  155. package/lib/CallbackRegistry.js +0 -91
  156. package/lib/LinkedValueMixin.js +0 -68
  157. package/lib/ex.js +0 -49
  158. package/lib/filterAttributes.js +0 -45
  159. package/lib/ge.js +0 -76
  160. package/lib/mutateHTMLNodeWithMarkup.js +0 -100
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013 Facebook, Inc.
2
+ * Copyright 2013-2014 Facebook, Inc.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -18,15 +18,20 @@
18
18
 
19
19
  "use strict";
20
20
 
21
- var CallbackRegistry = require("./CallbackRegistry");
22
21
  var EventPluginRegistry = require("./EventPluginRegistry");
23
22
  var EventPluginUtils = require("./EventPluginUtils");
24
- var EventPropagators = require("./EventPropagators");
25
23
  var ExecutionEnvironment = require("./ExecutionEnvironment");
26
24
 
27
25
  var accumulate = require("./accumulate");
28
26
  var forEachAccumulated = require("./forEachAccumulated");
29
27
  var invariant = require("./invariant");
28
+ var isEventSupported = require("./isEventSupported");
29
+ var monitorCodeUse = require("./monitorCodeUse");
30
+
31
+ /**
32
+ * Internal store for event listeners
33
+ */
34
+ var listenerBank = {};
30
35
 
31
36
  /**
32
37
  * Internal queue of events that have accumulated their dispatches and are
@@ -56,6 +61,21 @@ var executeDispatchesAndRelease = function(event) {
56
61
  }
57
62
  };
58
63
 
64
+ /**
65
+ * - `InstanceHandle`: [required] Module that performs logical traversals of DOM
66
+ * hierarchy given ids of the logical DOM elements involved.
67
+ */
68
+ var InstanceHandle = null;
69
+
70
+ function validateInstanceHandle() {
71
+ var invalid = !InstanceHandle||
72
+ !InstanceHandle.traverseTwoPhase ||
73
+ !InstanceHandle.traverseEnterLeave;
74
+ if (invalid) {
75
+ throw new Error('InstanceHandle not injected before use!');
76
+ }
77
+ }
78
+
59
79
  /**
60
80
  * This is a unified interface for event plugins to be installed and configured.
61
81
  *
@@ -85,11 +105,29 @@ var EventPluginHub = {
85
105
  */
86
106
  injection: {
87
107
 
108
+ /**
109
+ * @param {object} InjectedMount
110
+ * @public
111
+ */
112
+ injectMount: EventPluginUtils.injection.injectMount,
113
+
88
114
  /**
89
115
  * @param {object} InjectedInstanceHandle
90
116
  * @public
91
117
  */
92
- injectInstanceHandle: EventPropagators.injection.injectInstanceHandle,
118
+ injectInstanceHandle: function(InjectedInstanceHandle) {
119
+ InstanceHandle = InjectedInstanceHandle;
120
+ if ("production" !== process.env.NODE_ENV) {
121
+ validateInstanceHandle();
122
+ }
123
+ },
124
+
125
+ getInstanceHandle: function() {
126
+ if ("production" !== process.env.NODE_ENV) {
127
+ validateInstanceHandle();
128
+ }
129
+ return InstanceHandle;
130
+ },
93
131
 
94
132
  /**
95
133
  * @param {array} InjectedEventPluginOrder
@@ -104,15 +142,75 @@ var EventPluginHub = {
104
142
 
105
143
  },
106
144
 
107
- registrationNames: EventPluginRegistry.registrationNames,
145
+ eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
108
146
 
109
- putListener: CallbackRegistry.putListener,
147
+ registrationNameModules: EventPluginRegistry.registrationNameModules,
110
148
 
111
- getListener: CallbackRegistry.getListener,
149
+ /**
150
+ * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
151
+ *
152
+ * @param {string} id ID of the DOM element.
153
+ * @param {string} registrationName Name of listener (e.g. `onClick`).
154
+ * @param {?function} listener The callback to store.
155
+ */
156
+ putListener: function(id, registrationName, listener) {
157
+ ("production" !== process.env.NODE_ENV ? invariant(
158
+ ExecutionEnvironment.canUseDOM,
159
+ 'Cannot call putListener() in a non-DOM environment.'
160
+ ) : invariant(ExecutionEnvironment.canUseDOM));
161
+ ("production" !== process.env.NODE_ENV ? invariant(
162
+ !listener || typeof listener === 'function',
163
+ 'Expected %s listener to be a function, instead got type %s',
164
+ registrationName, typeof listener
165
+ ) : invariant(!listener || typeof listener === 'function'));
112
166
 
113
- deleteListener: CallbackRegistry.deleteListener,
167
+ if ("production" !== process.env.NODE_ENV) {
168
+ // IE8 has no API for event capturing and the `onScroll` event doesn't
169
+ // bubble.
170
+ if (registrationName === 'onScroll' &&
171
+ !isEventSupported('scroll', true)) {
172
+ monitorCodeUse('react_no_scroll_event');
173
+ console.warn('This browser doesn\'t support the `onScroll` event');
174
+ }
175
+ }
176
+ var bankForRegistrationName =
177
+ listenerBank[registrationName] || (listenerBank[registrationName] = {});
178
+ bankForRegistrationName[id] = listener;
179
+ },
114
180
 
115
- deleteAllListeners: CallbackRegistry.deleteAllListeners,
181
+ /**
182
+ * @param {string} id ID of the DOM element.
183
+ * @param {string} registrationName Name of listener (e.g. `onClick`).
184
+ * @return {?function} The stored callback.
185
+ */
186
+ getListener: function(id, registrationName) {
187
+ var bankForRegistrationName = listenerBank[registrationName];
188
+ return bankForRegistrationName && bankForRegistrationName[id];
189
+ },
190
+
191
+ /**
192
+ * Deletes a listener from the registration bank.
193
+ *
194
+ * @param {string} id ID of the DOM element.
195
+ * @param {string} registrationName Name of listener (e.g. `onClick`).
196
+ */
197
+ deleteListener: function(id, registrationName) {
198
+ var bankForRegistrationName = listenerBank[registrationName];
199
+ if (bankForRegistrationName) {
200
+ delete bankForRegistrationName[id];
201
+ }
202
+ },
203
+
204
+ /**
205
+ * Deletes all listeners for the DOM element with the supplied ID.
206
+ *
207
+ * @param {string} id ID of the DOM element.
208
+ */
209
+ deleteAllListeners: function(id) {
210
+ for (var registrationName in listenerBank) {
211
+ delete listenerBank[registrationName][id];
212
+ }
213
+ },
116
214
 
117
215
  /**
118
216
  * Allows registered plugins an opportunity to extract events from top-level
@@ -179,12 +277,19 @@ var EventPluginHub = {
179
277
  'processEventQueue(): Additional events were enqueued while processing ' +
180
278
  'an event queue. Support for this has not yet been implemented.'
181
279
  ) : invariant(!eventQueue));
280
+ },
281
+
282
+ /**
283
+ * These are needed for tests only. Do not use!
284
+ */
285
+ __purge: function() {
286
+ listenerBank = {};
287
+ },
288
+
289
+ __getListenerBank: function() {
290
+ return listenerBank;
182
291
  }
183
292
 
184
293
  };
185
294
 
186
- if (ExecutionEnvironment.canUseDOM) {
187
- window.EventPluginHub = EventPluginHub;
188
- }
189
-
190
295
  module.exports = EventPluginHub;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013 Facebook, Inc.
2
+ * Copyright 2013-2014 Facebook, Inc.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -63,11 +63,19 @@ function recomputePluginOrdering() {
63
63
  var publishedEvents = PluginModule.eventTypes;
64
64
  for (var eventName in publishedEvents) {
65
65
  ("production" !== process.env.NODE_ENV ? invariant(
66
- publishEventForPlugin(publishedEvents[eventName], PluginModule),
66
+ publishEventForPlugin(
67
+ publishedEvents[eventName],
68
+ PluginModule,
69
+ eventName
70
+ ),
67
71
  'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
68
72
  eventName,
69
73
  pluginName
70
- ) : invariant(publishEventForPlugin(publishedEvents[eventName], PluginModule)));
74
+ ) : invariant(publishEventForPlugin(
75
+ publishedEvents[eventName],
76
+ PluginModule,
77
+ eventName
78
+ )));
71
79
  }
72
80
  }
73
81
  }
@@ -80,18 +88,34 @@ function recomputePluginOrdering() {
80
88
  * @return {boolean} True if the event was successfully published.
81
89
  * @private
82
90
  */
83
- function publishEventForPlugin(dispatchConfig, PluginModule) {
91
+ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
92
+ ("production" !== process.env.NODE_ENV ? invariant(
93
+ !EventPluginRegistry.eventNameDispatchConfigs[eventName],
94
+ 'EventPluginHub: More than one plugin attempted to publish the same ' +
95
+ 'event name, `%s`.',
96
+ eventName
97
+ ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs[eventName]));
98
+ EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
99
+
84
100
  var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
85
101
  if (phasedRegistrationNames) {
86
102
  for (var phaseName in phasedRegistrationNames) {
87
103
  if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
88
104
  var phasedRegistrationName = phasedRegistrationNames[phaseName];
89
- publishRegistrationName(phasedRegistrationName, PluginModule);
105
+ publishRegistrationName(
106
+ phasedRegistrationName,
107
+ PluginModule,
108
+ eventName
109
+ );
90
110
  }
91
111
  }
92
112
  return true;
93
113
  } else if (dispatchConfig.registrationName) {
94
- publishRegistrationName(dispatchConfig.registrationName, PluginModule);
114
+ publishRegistrationName(
115
+ dispatchConfig.registrationName,
116
+ PluginModule,
117
+ eventName
118
+ );
95
119
  return true;
96
120
  }
97
121
  return false;
@@ -105,14 +129,16 @@ function publishEventForPlugin(dispatchConfig, PluginModule) {
105
129
  * @param {object} PluginModule Plugin publishing the event.
106
130
  * @private
107
131
  */
108
- function publishRegistrationName(registrationName, PluginModule) {
132
+ function publishRegistrationName(registrationName, PluginModule, eventName) {
109
133
  ("production" !== process.env.NODE_ENV ? invariant(
110
- !EventPluginRegistry.registrationNames[registrationName],
134
+ !EventPluginRegistry.registrationNameModules[registrationName],
111
135
  'EventPluginHub: More than one plugin attempted to publish the same ' +
112
136
  'registration name, `%s`.',
113
137
  registrationName
114
- ) : invariant(!EventPluginRegistry.registrationNames[registrationName]));
115
- EventPluginRegistry.registrationNames[registrationName] = PluginModule;
138
+ ) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
139
+ EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
140
+ EventPluginRegistry.registrationNameDependencies[registrationName] =
141
+ PluginModule.eventTypes[eventName].dependencies;
116
142
  }
117
143
 
118
144
  /**
@@ -128,9 +154,19 @@ var EventPluginRegistry = {
128
154
  plugins: [],
129
155
 
130
156
  /**
131
- * Mapping from registration names to plugin modules.
157
+ * Mapping from event name to dispatch config
132
158
  */
133
- registrationNames: {},
159
+ eventNameDispatchConfigs: {},
160
+
161
+ /**
162
+ * Mapping from registration name to plugin module
163
+ */
164
+ registrationNameModules: {},
165
+
166
+ /**
167
+ * Mapping from registration name to event name
168
+ */
169
+ registrationNameDependencies: {},
134
170
 
135
171
  /**
136
172
  * Injects an ordering of plugins (by plugin name). This allows the ordering
@@ -194,7 +230,7 @@ var EventPluginRegistry = {
194
230
  getPluginModuleForEvent: function(event) {
195
231
  var dispatchConfig = event.dispatchConfig;
196
232
  if (dispatchConfig.registrationName) {
197
- return EventPluginRegistry.registrationNames[
233
+ return EventPluginRegistry.registrationNameModules[
198
234
  dispatchConfig.registrationName
199
235
  ] || null;
200
236
  }
@@ -202,7 +238,7 @@ var EventPluginRegistry = {
202
238
  if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
203
239
  continue;
204
240
  }
205
- var PluginModule = EventPluginRegistry.registrationNames[
241
+ var PluginModule = EventPluginRegistry.registrationNameModules[
206
242
  dispatchConfig.phasedRegistrationNames[phase]
207
243
  ];
208
244
  if (PluginModule) {
@@ -224,10 +260,18 @@ var EventPluginRegistry = {
224
260
  }
225
261
  }
226
262
  EventPluginRegistry.plugins.length = 0;
227
- var registrationNames = EventPluginRegistry.registrationNames;
228
- for (var registrationName in registrationNames) {
229
- if (registrationNames.hasOwnProperty(registrationName)) {
230
- delete registrationNames[registrationName];
263
+
264
+ var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
265
+ for (var eventName in eventNameDispatchConfigs) {
266
+ if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
267
+ delete eventNameDispatchConfigs[eventName];
268
+ }
269
+ }
270
+
271
+ var registrationNameModules = EventPluginRegistry.registrationNameModules;
272
+ for (var registrationName in registrationNameModules) {
273
+ if (registrationNameModules.hasOwnProperty(registrationName)) {
274
+ delete registrationNameModules[registrationName];
231
275
  }
232
276
  }
233
277
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013 Facebook, Inc.
2
+ * Copyright 2013-2014 Facebook, Inc.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,28 @@ var EventConstants = require("./EventConstants");
22
22
 
23
23
  var invariant = require("./invariant");
24
24
 
25
+ /**
26
+ * Injected dependencies:
27
+ */
28
+
29
+ /**
30
+ * - `Mount`: [required] Module that can convert between React dom IDs and
31
+ * actual node references.
32
+ */
33
+ var injection = {
34
+ Mount: null,
35
+ injectMount: function(InjectedMount) {
36
+ injection.Mount = InjectedMount;
37
+ if ("production" !== process.env.NODE_ENV) {
38
+ ("production" !== process.env.NODE_ENV ? invariant(
39
+ InjectedMount && InjectedMount.getNode,
40
+ 'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
41
+ 'is missing getNode.'
42
+ ) : invariant(InjectedMount && InjectedMount.getNode));
43
+ }
44
+ }
45
+ };
46
+
25
47
  var topLevelTypes = EventConstants.topLevelTypes;
26
48
 
27
49
  function isEndish(topLevelType) {
@@ -39,6 +61,7 @@ function isStartish(topLevelType) {
39
61
  topLevelType === topLevelTypes.topTouchStart;
40
62
  }
41
63
 
64
+
42
65
  var validateEventDispatches;
43
66
  if ("production" !== process.env.NODE_ENV) {
44
67
  validateEventDispatches = function(event) {
@@ -90,7 +113,10 @@ function forEachEventDispatch(event, cb) {
90
113
  * @param {string} domID DOM id to pass to the callback.
91
114
  */
92
115
  function executeDispatch(event, listener, domID) {
93
- listener(event, domID);
116
+ event.currentTarget = injection.Mount.getNode(domID);
117
+ var returnValue = listener(event, domID);
118
+ event.currentTarget = null;
119
+ return returnValue;
94
120
  }
95
121
 
96
122
  /**
@@ -175,11 +201,14 @@ var EventPluginUtils = {
175
201
  isEndish: isEndish,
176
202
  isMoveish: isMoveish,
177
203
  isStartish: isStartish,
204
+
205
+ executeDirectDispatch: executeDirectDispatch,
206
+ executeDispatch: executeDispatch,
178
207
  executeDispatchesInOrder: executeDispatchesInOrder,
179
208
  executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
180
- executeDirectDispatch: executeDirectDispatch,
181
209
  hasDispatches: hasDispatches,
182
- executeDispatch: executeDispatch
210
+ injection: injection,
211
+ useTouchEvents: false
183
212
  };
184
213
 
185
214
  module.exports = EventPluginUtils;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013 Facebook, Inc.
2
+ * Copyright 2013-2014 Facebook, Inc.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -18,39 +18,14 @@
18
18
 
19
19
  "use strict";
20
20
 
21
- var CallbackRegistry = require("./CallbackRegistry");
22
21
  var EventConstants = require("./EventConstants");
22
+ var EventPluginHub = require("./EventPluginHub");
23
23
 
24
24
  var accumulate = require("./accumulate");
25
25
  var forEachAccumulated = require("./forEachAccumulated");
26
- var getListener = CallbackRegistry.getListener;
27
- var PropagationPhases = EventConstants.PropagationPhases;
28
26
 
29
- /**
30
- * Injected dependencies:
31
- */
32
-
33
- /**
34
- * - `InstanceHandle`: [required] Module that performs logical traversals of DOM
35
- * hierarchy given ids of the logical DOM elements involved.
36
- */
37
- var injection = {
38
- InstanceHandle: null,
39
- injectInstanceHandle: function(InjectedInstanceHandle) {
40
- injection.InstanceHandle = InjectedInstanceHandle;
41
- if ("production" !== process.env.NODE_ENV) {
42
- injection.validate();
43
- }
44
- },
45
- validate: function() {
46
- var invalid = !injection.InstanceHandle||
47
- !injection.InstanceHandle.traverseTwoPhase ||
48
- !injection.InstanceHandle.traverseEnterLeave;
49
- if (invalid) {
50
- throw new Error('InstanceHandle not injected before use!');
51
- }
52
- }
53
- };
27
+ var PropagationPhases = EventConstants.PropagationPhases;
28
+ var getListener = EventPluginHub.getListener;
54
29
 
55
30
  /**
56
31
  * Some event types have a notion of different registration names for different
@@ -73,7 +48,6 @@ function accumulateDirectionalDispatches(domID, upwards, event) {
73
48
  if (!domID) {
74
49
  throw new Error('Dispatching id must not be null');
75
50
  }
76
- injection.validate();
77
51
  }
78
52
  var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
79
53
  var listener = listenerAtPhase(domID, event, phase);
@@ -92,7 +66,7 @@ function accumulateDirectionalDispatches(domID, upwards, event) {
92
66
  */
93
67
  function accumulateTwoPhaseDispatchesSingle(event) {
94
68
  if (event && event.dispatchConfig.phasedRegistrationNames) {
95
- injection.InstanceHandle.traverseTwoPhase(
69
+ EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
96
70
  event.dispatchMarker,
97
71
  accumulateDirectionalDispatches,
98
72
  event
@@ -129,17 +103,11 @@ function accumulateDirectDispatchesSingle(event) {
129
103
  }
130
104
 
131
105
  function accumulateTwoPhaseDispatches(events) {
132
- if ("production" !== process.env.NODE_ENV) {
133
- injection.validate();
134
- }
135
106
  forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
136
107
  }
137
108
 
138
109
  function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
139
- if ("production" !== process.env.NODE_ENV) {
140
- injection.validate();
141
- }
142
- injection.InstanceHandle.traverseEnterLeave(
110
+ EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
143
111
  fromID,
144
112
  toID,
145
113
  accumulateDispatches,
@@ -150,9 +118,6 @@ function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
150
118
 
151
119
 
152
120
  function accumulateDirectDispatches(events) {
153
- if ("production" !== process.env.NODE_ENV) {
154
- injection.validate();
155
- }
156
121
  forEachAccumulated(events, accumulateDirectDispatchesSingle);
157
122
  }
158
123
 
@@ -172,8 +137,7 @@ function accumulateDirectDispatches(events) {
172
137
  var EventPropagators = {
173
138
  accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
174
139
  accumulateDirectDispatches: accumulateDirectDispatches,
175
- accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches,
176
- injection: injection
140
+ accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
177
141
  };
178
142
 
179
143
  module.exports = EventPropagators;