react 0.13.3 → 0.14.0-beta1

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 (189) hide show
  1. package/README.md +5 -2
  2. package/addons.js +7 -0
  3. package/dist/JSXTransformer.js +4101 -2432
  4. package/dist/react-with-addons.js +4389 -6277
  5. package/dist/react-with-addons.min.js +6 -8
  6. package/dist/react.js +4028 -5697
  7. package/dist/react.min.js +5 -6
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
  9. package/lib/BeforeInputEventPlugin.js +30 -118
  10. package/lib/CSSCore.js +12 -23
  11. package/lib/CSSProperty.js +4 -3
  12. package/lib/CSSPropertyOperations.js +14 -30
  13. package/lib/CallbackQueue.js +7 -10
  14. package/lib/ChangeEventPlugin.js +26 -88
  15. package/lib/ClientReactRootIndex.js +2 -2
  16. package/lib/DOMChildrenOperations.js +13 -33
  17. package/lib/DOMProperty.js +86 -147
  18. package/lib/DOMPropertyOperations.js +91 -67
  19. package/lib/Danger.js +19 -62
  20. package/lib/DefaultEventPluginOrder.js +2 -12
  21. package/lib/EnterLeaveEventPlugin.js +11 -33
  22. package/lib/EventConstants.js +2 -2
  23. package/lib/EventListener.js +11 -13
  24. package/lib/EventPluginHub.js +44 -47
  25. package/lib/EventPluginRegistry.js +18 -74
  26. package/lib/EventPluginUtils.js +33 -44
  27. package/lib/EventPropagators.js +23 -26
  28. package/lib/ExecutionEnvironment.js +4 -8
  29. package/lib/FallbackCompositionState.js +3 -3
  30. package/lib/HTMLDOMPropertyConfig.js +15 -20
  31. package/lib/LinkedStateMixin.js +3 -6
  32. package/lib/LinkedValueUtils.js +71 -89
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +20 -11
  35. package/lib/React.js +9 -129
  36. package/lib/ReactBrowserComponentMixin.js +9 -2
  37. package/lib/ReactBrowserEventEmitter.js +26 -82
  38. package/lib/ReactCSSTransitionGroup.js +13 -24
  39. package/lib/ReactCSSTransitionGroupChild.js +26 -28
  40. package/lib/ReactChildReconciler.js +11 -19
  41. package/lib/ReactChildren.js +24 -31
  42. package/lib/ReactClass.js +96 -267
  43. package/lib/ReactComponent.js +28 -57
  44. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  45. package/lib/ReactComponentEnvironment.js +6 -12
  46. package/lib/ReactComponentWithPureRenderMixin.js +6 -7
  47. package/lib/ReactCompositeComponent.js +115 -381
  48. package/lib/ReactCurrentOwner.js +1 -3
  49. package/lib/ReactDOM.js +4 -2
  50. package/lib/ReactDOMButton.js +16 -28
  51. package/lib/ReactDOMClient.js +90 -0
  52. package/lib/ReactDOMComponent.js +468 -156
  53. package/lib/ReactDOMIDOperations.js +25 -22
  54. package/lib/ReactDOMInput.js +79 -108
  55. package/lib/ReactDOMOption.js +58 -20
  56. package/lib/ReactDOMSelect.js +95 -83
  57. package/lib/ReactDOMSelection.js +5 -20
  58. package/lib/ReactDOMServer.js +24 -0
  59. package/lib/ReactDOMTextComponent.js +17 -18
  60. package/lib/ReactDOMTextarea.js +44 -69
  61. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  62. package/lib/ReactDefaultInjection.js +20 -76
  63. package/lib/ReactDefaultPerf.js +36 -69
  64. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  65. package/lib/ReactElement.js +26 -120
  66. package/lib/ReactElementValidator.js +56 -192
  67. package/lib/ReactEmptyComponent.js +7 -11
  68. package/lib/ReactErrorUtils.js +3 -3
  69. package/lib/ReactEventEmitterMixin.js +3 -13
  70. package/lib/ReactEventListener.js +58 -40
  71. package/lib/ReactFragment.js +33 -59
  72. package/lib/ReactInjection.js +1 -1
  73. package/lib/ReactInputSelection.js +14 -23
  74. package/lib/ReactInstanceHandles.js +29 -58
  75. package/lib/ReactInstanceMap.js +5 -5
  76. package/lib/ReactIsomorphic.js +70 -0
  77. package/lib/ReactLink.js +2 -4
  78. package/lib/ReactMarkupChecksum.js +5 -10
  79. package/lib/ReactMount.js +142 -285
  80. package/lib/ReactMultiChild.js +19 -45
  81. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  82. package/lib/ReactNativeComponent.js +6 -15
  83. package/lib/ReactNoopUpdateQueue.js +118 -0
  84. package/lib/ReactOwner.js +7 -24
  85. package/lib/ReactPerf.js +8 -12
  86. package/lib/ReactPropTransferer.js +4 -4
  87. package/lib/ReactPropTypeLocationNames.js +2 -2
  88. package/lib/ReactPropTypeLocations.js +1 -1
  89. package/lib/ReactPropTypes.js +41 -61
  90. package/lib/ReactReconcileTransaction.js +11 -36
  91. package/lib/ReactReconciler.js +14 -26
  92. package/lib/ReactRef.js +5 -8
  93. package/lib/ReactRootIndex.js +2 -2
  94. package/lib/ReactServerBatchingStrategy.js +23 -0
  95. package/lib/ReactServerRendering.js +20 -15
  96. package/lib/ReactServerRenderingTransaction.js +9 -34
  97. package/lib/ReactStateSetters.js +6 -6
  98. package/lib/ReactTestUtils.js +137 -190
  99. package/lib/ReactTransitionChildMapping.js +5 -7
  100. package/lib/ReactTransitionEvents.js +5 -5
  101. package/lib/ReactTransitionGroup.js +30 -52
  102. package/lib/ReactUpdateQueue.js +69 -107
  103. package/lib/ReactUpdates.js +26 -81
  104. package/lib/ReactWithAddons.js +5 -6
  105. package/lib/SVGDOMPropertyConfig.js +39 -4
  106. package/lib/SelectEventPlugin.js +31 -33
  107. package/lib/ServerReactRootIndex.js +2 -2
  108. package/lib/SimpleEventPlugin.js +138 -130
  109. package/lib/SyntheticClipboardEvent.js +5 -9
  110. package/lib/SyntheticCompositionEvent.js +4 -10
  111. package/lib/SyntheticDragEvent.js +3 -3
  112. package/lib/SyntheticEvent.js +14 -15
  113. package/lib/SyntheticFocusEvent.js +3 -3
  114. package/lib/SyntheticInputEvent.js +4 -10
  115. package/lib/SyntheticKeyboardEvent.js +6 -6
  116. package/lib/SyntheticMouseEvent.js +10 -16
  117. package/lib/SyntheticTouchEvent.js +3 -3
  118. package/lib/SyntheticUIEvent.js +5 -5
  119. package/lib/SyntheticWheelEvent.js +13 -17
  120. package/lib/Transaction.js +22 -28
  121. package/lib/ViewportMetrics.js +2 -2
  122. package/lib/accumulateInto.js +2 -5
  123. package/lib/adler32.js +2 -4
  124. package/lib/camelize.js +4 -2
  125. package/lib/camelizeStyleName.js +2 -2
  126. package/lib/cloneWithProps.js +6 -12
  127. package/lib/containsNode.js +29 -16
  128. package/lib/createArrayFromMixed.js +17 -16
  129. package/lib/createNodesFromMarkup.js +6 -8
  130. package/lib/dangerousStyleValue.js +2 -3
  131. package/lib/deprecated.js +47 -0
  132. package/lib/emptyFunction.js +10 -4
  133. package/lib/emptyObject.js +1 -1
  134. package/lib/escapeTextContentForBrowser.js +1 -1
  135. package/lib/findDOMNode.js +7 -27
  136. package/lib/flattenChildren.js +4 -10
  137. package/lib/focusNode.js +2 -3
  138. package/lib/forEachAccumulated.js +3 -3
  139. package/lib/getActiveElement.js +4 -2
  140. package/lib/getEventCharCode.js +2 -2
  141. package/lib/getEventKey.js +1 -1
  142. package/lib/getEventModifierState.js +1 -2
  143. package/lib/getEventTarget.js +1 -1
  144. package/lib/getIteratorFn.js +2 -4
  145. package/lib/getMarkupWrap.js +18 -40
  146. package/lib/getNodeForCharacterOffset.js +1 -1
  147. package/lib/getTextContentAccessor.js +2 -4
  148. package/lib/getUnboundedScrollPosition.js +1 -1
  149. package/lib/hyphenate.js +3 -1
  150. package/lib/hyphenateStyleName.js +2 -2
  151. package/lib/instantiateReactComponent.js +23 -43
  152. package/lib/invariant.js +8 -12
  153. package/lib/isEventSupported.js +7 -10
  154. package/lib/isNode.js +4 -6
  155. package/lib/isTextInputElement.js +3 -4
  156. package/lib/isTextNode.js +3 -1
  157. package/lib/joinClasses.js +3 -3
  158. package/lib/keyMirror.js +3 -6
  159. package/lib/keyOf.js +4 -3
  160. package/lib/mapObject.js +1 -1
  161. package/lib/memoizeStringOnly.js +2 -2
  162. package/lib/onlyChild.js +2 -5
  163. package/lib/performance.js +2 -5
  164. package/lib/performanceNow.js +3 -1
  165. package/lib/quoteAttributeValueForBrowser.js +1 -1
  166. package/lib/renderSubtreeIntoContainer.js +16 -0
  167. package/lib/setInnerHTML.js +11 -8
  168. package/lib/setTextContent.js +3 -3
  169. package/lib/shallowCompare.js +24 -0
  170. package/lib/shallowEqual.js +17 -11
  171. package/lib/shouldUpdateReactComponent.js +3 -64
  172. package/lib/toArray.js +8 -19
  173. package/lib/traverseAllChildren.js +23 -90
  174. package/lib/update.js +25 -85
  175. package/lib/validateDOMNesting.js +363 -0
  176. package/lib/warning.js +15 -17
  177. package/package.json +3 -3
  178. package/react.js +53 -1
  179. package/lib/LocalEventTrapMixin.js +0 -53
  180. package/lib/MobileSafariClickEventPlugin.js +0 -56
  181. package/lib/ReactContext.js +0 -74
  182. package/lib/ReactDOMForm.js +0 -47
  183. package/lib/ReactDOMIframe.js +0 -43
  184. package/lib/ReactDOMImg.js +0 -44
  185. package/lib/ReactLifeCycle.js +0 -35
  186. package/lib/ReactPutListenerQueue.js +0 -54
  187. package/lib/createFullPageComponent.js +0 -58
  188. package/lib/cx.js +0 -52
  189. package/lib/getReactRootElementInContainer.js +0 -33
@@ -13,7 +13,7 @@
13
13
 
14
14
  var keyMirror = require("./keyMirror");
15
15
 
16
- var PropagationPhases = keyMirror({bubbled: null, captured: null});
16
+ var PropagationPhases = keyMirror({ bubbled: null, captured: null });
17
17
 
18
18
  /**
19
19
  * Types of raw signals from the browser caught at the top level.
@@ -67,4 +67,4 @@ var EventConstants = {
67
67
  PropagationPhases: PropagationPhases
68
68
  };
69
69
 
70
- module.exports = EventConstants;
70
+ module.exports = EventConstants;
@@ -17,6 +17,8 @@
17
17
  * @typechecks
18
18
  */
19
19
 
20
+ 'use strict';
21
+
20
22
  var emptyFunction = require("./emptyFunction");
21
23
 
22
24
  /**
@@ -32,18 +34,18 @@ var EventListener = {
32
34
  * @param {function} callback Callback function.
33
35
  * @return {object} Object with a `remove` method.
34
36
  */
35
- listen: function(target, eventType, callback) {
37
+ listen: function (target, eventType, callback) {
36
38
  if (target.addEventListener) {
37
39
  target.addEventListener(eventType, callback, false);
38
40
  return {
39
- remove: function() {
41
+ remove: function () {
40
42
  target.removeEventListener(eventType, callback, false);
41
43
  }
42
44
  };
43
45
  } else if (target.attachEvent) {
44
46
  target.attachEvent('on' + eventType, callback);
45
47
  return {
46
- remove: function() {
48
+ remove: function () {
47
49
  target.detachEvent('on' + eventType, callback);
48
50
  }
49
51
  };
@@ -58,14 +60,10 @@ var EventListener = {
58
60
  * @param {function} callback Callback function.
59
61
  * @return {object} Object with a `remove` method.
60
62
  */
61
- capture: function(target, eventType, callback) {
63
+ capture: function (target, eventType, callback) {
62
64
  if (!target.addEventListener) {
63
- if ("production" !== process.env.NODE_ENV) {
64
- console.error(
65
- 'Attempted to listen to events during the capture phase on a ' +
66
- 'browser that does not support the capture phase. Your application ' +
67
- 'will not receive some events.'
68
- );
65
+ if ('production' !== process.env.NODE_ENV) {
66
+ console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.');
69
67
  }
70
68
  return {
71
69
  remove: emptyFunction
@@ -73,14 +71,14 @@ var EventListener = {
73
71
  } else {
74
72
  target.addEventListener(eventType, callback, true);
75
73
  return {
76
- remove: function() {
74
+ remove: function () {
77
75
  target.removeEventListener(eventType, callback, true);
78
76
  }
79
77
  };
80
78
  }
81
79
  },
82
80
 
83
- registerDefault: function() {}
81
+ registerDefault: function () {}
84
82
  };
85
83
 
86
- module.exports = EventListener;
84
+ module.exports = EventListener;
@@ -17,6 +17,7 @@ var EventPluginUtils = require("./EventPluginUtils");
17
17
  var accumulateInto = require("./accumulateInto");
18
18
  var forEachAccumulated = require("./forEachAccumulated");
19
19
  var invariant = require("./invariant");
20
+ var warning = require("./warning");
20
21
 
21
22
  /**
22
23
  * Internal store for event listeners
@@ -35,7 +36,7 @@ var eventQueue = null;
35
36
  * @param {?object} event Synthetic event to be dispatched.
36
37
  * @private
37
38
  */
38
- var executeDispatchesAndRelease = function(event) {
39
+ var executeDispatchesAndRelease = function (event) {
39
40
  if (event) {
40
41
  var executeDispatch = EventPluginUtils.executeDispatch;
41
42
  // Plugins can provide custom behavior when dispatching events.
@@ -58,14 +59,8 @@ var executeDispatchesAndRelease = function(event) {
58
59
  var InstanceHandle = null;
59
60
 
60
61
  function validateInstanceHandle() {
61
- var valid =
62
- InstanceHandle &&
63
- InstanceHandle.traverseTwoPhase &&
64
- InstanceHandle.traverseEnterLeave;
65
- ("production" !== process.env.NODE_ENV ? invariant(
66
- valid,
67
- 'InstanceHandle not injected before use!'
68
- ) : invariant(valid));
62
+ var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
63
+ 'production' !== process.env.NODE_ENV ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
69
64
  }
70
65
 
71
66
  /**
@@ -107,15 +102,15 @@ var EventPluginHub = {
107
102
  * @param {object} InjectedInstanceHandle
108
103
  * @public
109
104
  */
110
- injectInstanceHandle: function(InjectedInstanceHandle) {
105
+ injectInstanceHandle: function (InjectedInstanceHandle) {
111
106
  InstanceHandle = InjectedInstanceHandle;
112
- if ("production" !== process.env.NODE_ENV) {
107
+ if ('production' !== process.env.NODE_ENV) {
113
108
  validateInstanceHandle();
114
109
  }
115
110
  },
116
111
 
117
- getInstanceHandle: function() {
118
- if ("production" !== process.env.NODE_ENV) {
112
+ getInstanceHandle: function () {
113
+ if ('production' !== process.env.NODE_ENV) {
119
114
  validateInstanceHandle();
120
115
  }
121
116
  return InstanceHandle;
@@ -145,16 +140,16 @@ var EventPluginHub = {
145
140
  * @param {string} registrationName Name of listener (e.g. `onClick`).
146
141
  * @param {?function} listener The callback to store.
147
142
  */
148
- putListener: function(id, registrationName, listener) {
149
- ("production" !== process.env.NODE_ENV ? invariant(
150
- !listener || typeof listener === 'function',
151
- 'Expected %s listener to be a function, instead got type %s',
152
- registrationName, typeof listener
153
- ) : invariant(!listener || typeof listener === 'function'));
154
-
155
- var bankForRegistrationName =
156
- listenerBank[registrationName] || (listenerBank[registrationName] = {});
143
+ putListener: function (id, registrationName, listener) {
144
+ !(typeof listener === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : undefined;
145
+
146
+ var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
157
147
  bankForRegistrationName[id] = listener;
148
+
149
+ var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
150
+ if (PluginModule && PluginModule.didPutListener) {
151
+ PluginModule.didPutListener(id, registrationName, listener);
152
+ }
158
153
  },
159
154
 
160
155
  /**
@@ -162,7 +157,7 @@ var EventPluginHub = {
162
157
  * @param {string} registrationName Name of listener (e.g. `onClick`).
163
158
  * @return {?function} The stored callback.
164
159
  */
165
- getListener: function(id, registrationName) {
160
+ getListener: function (id, registrationName) {
166
161
  var bankForRegistrationName = listenerBank[registrationName];
167
162
  return bankForRegistrationName && bankForRegistrationName[id];
168
163
  },
@@ -173,8 +168,14 @@ var EventPluginHub = {
173
168
  * @param {string} id ID of the DOM element.
174
169
  * @param {string} registrationName Name of listener (e.g. `onClick`).
175
170
  */
176
- deleteListener: function(id, registrationName) {
171
+ deleteListener: function (id, registrationName) {
172
+ var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
173
+ if (PluginModule && PluginModule.willDeleteListener) {
174
+ PluginModule.willDeleteListener(id, registrationName);
175
+ }
176
+
177
177
  var bankForRegistrationName = listenerBank[registrationName];
178
+ // TODO: This should never be null -- when is it?
178
179
  if (bankForRegistrationName) {
179
180
  delete bankForRegistrationName[id];
180
181
  }
@@ -185,8 +186,17 @@ var EventPluginHub = {
185
186
  *
186
187
  * @param {string} id ID of the DOM element.
187
188
  */
188
- deleteAllListeners: function(id) {
189
+ deleteAllListeners: function (id) {
189
190
  for (var registrationName in listenerBank) {
191
+ if (!listenerBank[registrationName][id]) {
192
+ continue;
193
+ }
194
+
195
+ var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
196
+ if (PluginModule && PluginModule.willDeleteListener) {
197
+ PluginModule.willDeleteListener(id, registrationName);
198
+ }
199
+
190
200
  delete listenerBank[registrationName][id];
191
201
  }
192
202
  },
@@ -202,23 +212,14 @@ var EventPluginHub = {
202
212
  * @return {*} An accumulation of synthetic events.
203
213
  * @internal
204
214
  */
205
- extractEvents: function(
206
- topLevelType,
207
- topLevelTarget,
208
- topLevelTargetID,
209
- nativeEvent) {
215
+ extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
210
216
  var events;
211
217
  var plugins = EventPluginRegistry.plugins;
212
- for (var i = 0, l = plugins.length; i < l; i++) {
218
+ for (var i = 0; i < plugins.length; i++) {
213
219
  // Not every plugin in the ordering may be loaded at runtime.
214
220
  var possiblePlugin = plugins[i];
215
221
  if (possiblePlugin) {
216
- var extractedEvents = possiblePlugin.extractEvents(
217
- topLevelType,
218
- topLevelTarget,
219
- topLevelTargetID,
220
- nativeEvent
221
- );
222
+ var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
222
223
  if (extractedEvents) {
223
224
  events = accumulateInto(events, extractedEvents);
224
225
  }
@@ -234,7 +235,7 @@ var EventPluginHub = {
234
235
  * @param {*} events An accumulation of synthetic events.
235
236
  * @internal
236
237
  */
237
- enqueueEvents: function(events) {
238
+ enqueueEvents: function (events) {
238
239
  if (events) {
239
240
  eventQueue = accumulateInto(eventQueue, events);
240
241
  }
@@ -245,30 +246,26 @@ var EventPluginHub = {
245
246
  *
246
247
  * @internal
247
248
  */
248
- processEventQueue: function() {
249
+ processEventQueue: function () {
249
250
  // Set `eventQueue` to null before processing it so that we can tell if more
250
251
  // events get enqueued while processing.
251
252
  var processingEventQueue = eventQueue;
252
253
  eventQueue = null;
253
254
  forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
254
- ("production" !== process.env.NODE_ENV ? invariant(
255
- !eventQueue,
256
- 'processEventQueue(): Additional events were enqueued while processing ' +
257
- 'an event queue. Support for this has not yet been implemented.'
258
- ) : invariant(!eventQueue));
255
+ !!eventQueue ? 'production' !== process.env.NODE_ENV ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) : undefined;
259
256
  },
260
257
 
261
258
  /**
262
259
  * These are needed for tests only. Do not use!
263
260
  */
264
- __purge: function() {
261
+ __purge: function () {
265
262
  listenerBank = {};
266
263
  },
267
264
 
268
- __getListenerBank: function() {
265
+ __getListenerBank: function () {
269
266
  return listenerBank;
270
267
  }
271
268
 
272
269
  };
273
270
 
274
- module.exports = EventPluginHub;
271
+ module.exports = EventPluginHub;
@@ -37,38 +37,15 @@ function recomputePluginOrdering() {
37
37
  for (var pluginName in namesToPlugins) {
38
38
  var PluginModule = namesToPlugins[pluginName];
39
39
  var pluginIndex = EventPluginOrder.indexOf(pluginName);
40
- ("production" !== process.env.NODE_ENV ? invariant(
41
- pluginIndex > -1,
42
- 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
43
- 'the plugin ordering, `%s`.',
44
- pluginName
45
- ) : invariant(pluginIndex > -1));
40
+ !(pluginIndex > -1) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined;
46
41
  if (EventPluginRegistry.plugins[pluginIndex]) {
47
42
  continue;
48
43
  }
49
- ("production" !== process.env.NODE_ENV ? invariant(
50
- PluginModule.extractEvents,
51
- 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
52
- 'method, but `%s` does not.',
53
- pluginName
54
- ) : invariant(PluginModule.extractEvents));
44
+ !PluginModule.extractEvents ? 'production' !== process.env.NODE_ENV ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined;
55
45
  EventPluginRegistry.plugins[pluginIndex] = PluginModule;
56
46
  var publishedEvents = PluginModule.eventTypes;
57
47
  for (var eventName in publishedEvents) {
58
- ("production" !== process.env.NODE_ENV ? invariant(
59
- publishEventForPlugin(
60
- publishedEvents[eventName],
61
- PluginModule,
62
- eventName
63
- ),
64
- 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
65
- eventName,
66
- pluginName
67
- ) : invariant(publishEventForPlugin(
68
- publishedEvents[eventName],
69
- PluginModule,
70
- eventName
71
- )));
48
+ !publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined;
72
49
  }
73
50
  }
74
51
  }
@@ -82,12 +59,7 @@ function recomputePluginOrdering() {
82
59
  * @private
83
60
  */
84
61
  function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
85
- ("production" !== process.env.NODE_ENV ? invariant(
86
- !EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
87
- 'EventPluginHub: More than one plugin attempted to publish the same ' +
88
- 'event name, `%s`.',
89
- eventName
90
- ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
62
+ !!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined;
91
63
  EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
92
64
 
93
65
  var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
@@ -95,20 +67,12 @@ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
95
67
  for (var phaseName in phasedRegistrationNames) {
96
68
  if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
97
69
  var phasedRegistrationName = phasedRegistrationNames[phaseName];
98
- publishRegistrationName(
99
- phasedRegistrationName,
100
- PluginModule,
101
- eventName
102
- );
70
+ publishRegistrationName(phasedRegistrationName, PluginModule, eventName);
103
71
  }
104
72
  }
105
73
  return true;
106
74
  } else if (dispatchConfig.registrationName) {
107
- publishRegistrationName(
108
- dispatchConfig.registrationName,
109
- PluginModule,
110
- eventName
111
- );
75
+ publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName);
112
76
  return true;
113
77
  }
114
78
  return false;
@@ -123,15 +87,9 @@ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
123
87
  * @private
124
88
  */
125
89
  function publishRegistrationName(registrationName, PluginModule, eventName) {
126
- ("production" !== process.env.NODE_ENV ? invariant(
127
- !EventPluginRegistry.registrationNameModules[registrationName],
128
- 'EventPluginHub: More than one plugin attempted to publish the same ' +
129
- 'registration name, `%s`.',
130
- registrationName
131
- ) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
90
+ !!EventPluginRegistry.registrationNameModules[registrationName] ? 'production' !== process.env.NODE_ENV ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
132
91
  EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
133
- EventPluginRegistry.registrationNameDependencies[registrationName] =
134
- PluginModule.eventTypes[eventName].dependencies;
92
+ EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
135
93
  }
136
94
 
137
95
  /**
@@ -170,12 +128,8 @@ var EventPluginRegistry = {
170
128
  * @internal
171
129
  * @see {EventPluginHub.injection.injectEventPluginOrder}
172
130
  */
173
- injectEventPluginOrder: function(InjectedEventPluginOrder) {
174
- ("production" !== process.env.NODE_ENV ? invariant(
175
- !EventPluginOrder,
176
- 'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
177
- 'once. You are likely trying to load more than one copy of React.'
178
- ) : invariant(!EventPluginOrder));
131
+ injectEventPluginOrder: function (InjectedEventPluginOrder) {
132
+ !!EventPluginOrder ? 'production' !== process.env.NODE_ENV ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : undefined;
179
133
  // Clone the ordering so it cannot be dynamically mutated.
180
134
  EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
181
135
  recomputePluginOrdering();
@@ -191,21 +145,15 @@ var EventPluginRegistry = {
191
145
  * @internal
192
146
  * @see {EventPluginHub.injection.injectEventPluginsByName}
193
147
  */
194
- injectEventPluginsByName: function(injectedNamesToPlugins) {
148
+ injectEventPluginsByName: function (injectedNamesToPlugins) {
195
149
  var isOrderingDirty = false;
196
150
  for (var pluginName in injectedNamesToPlugins) {
197
151
  if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
198
152
  continue;
199
153
  }
200
154
  var PluginModule = injectedNamesToPlugins[pluginName];
201
- if (!namesToPlugins.hasOwnProperty(pluginName) ||
202
- namesToPlugins[pluginName] !== PluginModule) {
203
- ("production" !== process.env.NODE_ENV ? invariant(
204
- !namesToPlugins[pluginName],
205
- 'EventPluginRegistry: Cannot inject two different event plugins ' +
206
- 'using the same name, `%s`.',
207
- pluginName
208
- ) : invariant(!namesToPlugins[pluginName]));
155
+ if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
156
+ !!namesToPlugins[pluginName] ? 'production' !== process.env.NODE_ENV ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : undefined;
209
157
  namesToPlugins[pluginName] = PluginModule;
210
158
  isOrderingDirty = true;
211
159
  }
@@ -222,20 +170,16 @@ var EventPluginRegistry = {
222
170
  * @return {?object} The plugin that created the supplied event.
223
171
  * @internal
224
172
  */
225
- getPluginModuleForEvent: function(event) {
173
+ getPluginModuleForEvent: function (event) {
226
174
  var dispatchConfig = event.dispatchConfig;
227
175
  if (dispatchConfig.registrationName) {
228
- return EventPluginRegistry.registrationNameModules[
229
- dispatchConfig.registrationName
230
- ] || null;
176
+ return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
231
177
  }
232
178
  for (var phase in dispatchConfig.phasedRegistrationNames) {
233
179
  if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
234
180
  continue;
235
181
  }
236
- var PluginModule = EventPluginRegistry.registrationNameModules[
237
- dispatchConfig.phasedRegistrationNames[phase]
238
- ];
182
+ var PluginModule = EventPluginRegistry.registrationNameModules[dispatchConfig.phasedRegistrationNames[phase]];
239
183
  if (PluginModule) {
240
184
  return PluginModule;
241
185
  }
@@ -247,7 +191,7 @@ var EventPluginRegistry = {
247
191
  * Exposed for unit testing.
248
192
  * @private
249
193
  */
250
- _resetEventPlugins: function() {
194
+ _resetEventPlugins: function () {
251
195
  EventPluginOrder = null;
252
196
  for (var pluginName in namesToPlugins) {
253
197
  if (namesToPlugins.hasOwnProperty(pluginName)) {
@@ -273,4 +217,4 @@ var EventPluginRegistry = {
273
217
 
274
218
  };
275
219
 
276
- module.exports = EventPluginRegistry;
220
+ module.exports = EventPluginRegistry;
@@ -14,6 +14,7 @@
14
14
  var EventConstants = require("./EventConstants");
15
15
 
16
16
  var invariant = require("./invariant");
17
+ var warning = require("./warning");
17
18
 
18
19
  /**
19
20
  * Injected dependencies:
@@ -25,14 +26,10 @@ var invariant = require("./invariant");
25
26
  */
26
27
  var injection = {
27
28
  Mount: null,
28
- injectMount: function(InjectedMount) {
29
+ injectMount: function (InjectedMount) {
29
30
  injection.Mount = InjectedMount;
30
- if ("production" !== process.env.NODE_ENV) {
31
- ("production" !== process.env.NODE_ENV ? invariant(
32
- InjectedMount && InjectedMount.getNode,
33
- 'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
34
- 'is missing getNode.'
35
- ) : invariant(InjectedMount && InjectedMount.getNode));
31
+ if ('production' !== process.env.NODE_ENV) {
32
+ 'production' !== process.env.NODE_ENV ? warning(InjectedMount && InjectedMount.getNode && InjectedMount.getID, 'EventPluginUtils.injection.injectMount(...): Injected Mount ' + 'module is missing getNode or getID.') : undefined;
36
33
  }
37
34
  }
38
35
  };
@@ -40,38 +37,28 @@ var injection = {
40
37
  var topLevelTypes = EventConstants.topLevelTypes;
41
38
 
42
39
  function isEndish(topLevelType) {
43
- return topLevelType === topLevelTypes.topMouseUp ||
44
- topLevelType === topLevelTypes.topTouchEnd ||
45
- topLevelType === topLevelTypes.topTouchCancel;
40
+ return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel;
46
41
  }
47
42
 
48
43
  function isMoveish(topLevelType) {
49
- return topLevelType === topLevelTypes.topMouseMove ||
50
- topLevelType === topLevelTypes.topTouchMove;
44
+ return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove;
51
45
  }
52
46
  function isStartish(topLevelType) {
53
- return topLevelType === topLevelTypes.topMouseDown ||
54
- topLevelType === topLevelTypes.topTouchStart;
47
+ return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart;
55
48
  }
56
49
 
57
-
58
50
  var validateEventDispatches;
59
- if ("production" !== process.env.NODE_ENV) {
60
- validateEventDispatches = function(event) {
51
+ if ('production' !== process.env.NODE_ENV) {
52
+ validateEventDispatches = function (event) {
61
53
  var dispatchListeners = event._dispatchListeners;
62
54
  var dispatchIDs = event._dispatchIDs;
63
55
 
64
56
  var listenersIsArr = Array.isArray(dispatchListeners);
65
57
  var idsIsArr = Array.isArray(dispatchIDs);
66
58
  var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
67
- var listenersLen = listenersIsArr ?
68
- dispatchListeners.length :
69
- dispatchListeners ? 1 : 0;
70
-
71
- ("production" !== process.env.NODE_ENV ? invariant(
72
- idsIsArr === listenersIsArr && IDsLen === listenersLen,
73
- 'EventPluginUtils: Invalid `event`.'
74
- ) : invariant(idsIsArr === listenersIsArr && IDsLen === listenersLen));
59
+ var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
60
+
61
+ 'production' !== process.env.NODE_ENV ? warning(idsIsArr === listenersIsArr && IDsLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined;
75
62
  };
76
63
  }
77
64
 
@@ -83,7 +70,7 @@ if ("production" !== process.env.NODE_ENV) {
83
70
  function forEachEventDispatch(event, cb) {
84
71
  var dispatchListeners = event._dispatchListeners;
85
72
  var dispatchIDs = event._dispatchIDs;
86
- if ("production" !== process.env.NODE_ENV) {
73
+ if ('production' !== process.env.NODE_ENV) {
87
74
  validateEventDispatches(event);
88
75
  }
89
76
  if (Array.isArray(dispatchListeners)) {
@@ -101,8 +88,8 @@ function forEachEventDispatch(event, cb) {
101
88
 
102
89
  /**
103
90
  * Default implementation of PluginModule.executeDispatch().
104
- * @param {SyntheticEvent} SyntheticEvent to handle
105
- * @param {function} Application-level callback
91
+ * @param {SyntheticEvent} event SyntheticEvent to handle
92
+ * @param {function} listener Application-level callback
106
93
  * @param {string} domID DOM id to pass to the callback.
107
94
  */
108
95
  function executeDispatch(event, listener, domID) {
@@ -125,13 +112,13 @@ function executeDispatchesInOrder(event, cb) {
125
112
  * Standard/simple iteration through an event's collected dispatches, but stops
126
113
  * at the first dispatch execution returning true, and returns that id.
127
114
  *
128
- * @return id of the first dispatch execution who's listener returns true, or
129
- * null if no listener returned true.
115
+ * @return {?string} id of the first dispatch execution who's listener returns
116
+ * true, or null if no listener returned true.
130
117
  */
131
118
  function executeDispatchesInOrderStopAtTrueImpl(event) {
132
119
  var dispatchListeners = event._dispatchListeners;
133
120
  var dispatchIDs = event._dispatchIDs;
134
- if ("production" !== process.env.NODE_ENV) {
121
+ if ('production' !== process.env.NODE_ENV) {
135
122
  validateEventDispatches(event);
136
123
  }
137
124
  if (Array.isArray(dispatchListeners)) {
@@ -169,21 +156,16 @@ function executeDispatchesInOrderStopAtTrue(event) {
169
156
  * return values at each dispatch execution, but it does tend to make sense when
170
157
  * dealing with "direct" dispatches.
171
158
  *
172
- * @return The return value of executing the single dispatch.
159
+ * @return {*} The return value of executing the single dispatch.
173
160
  */
174
161
  function executeDirectDispatch(event) {
175
- if ("production" !== process.env.NODE_ENV) {
162
+ if ('production' !== process.env.NODE_ENV) {
176
163
  validateEventDispatches(event);
177
164
  }
178
165
  var dispatchListener = event._dispatchListeners;
179
166
  var dispatchID = event._dispatchIDs;
180
- ("production" !== process.env.NODE_ENV ? invariant(
181
- !Array.isArray(dispatchListener),
182
- 'executeDirectDispatch(...): Invalid `event`.'
183
- ) : invariant(!Array.isArray(dispatchListener)));
184
- var res = dispatchListener ?
185
- dispatchListener(event, dispatchID) :
186
- null;
167
+ !!Array.isArray(dispatchListener) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined;
168
+ var res = dispatchListener ? dispatchListener(event, dispatchID) : null;
187
169
  event._dispatchListeners = null;
188
170
  event._dispatchIDs = null;
189
171
  return res;
@@ -191,7 +173,7 @@ function executeDirectDispatch(event) {
191
173
 
192
174
  /**
193
175
  * @param {SyntheticEvent} event
194
- * @return {bool} True iff number of dispatches accumulated is greater than 0.
176
+ * @return {boolean} True iff number of dispatches accumulated is greater than 0.
195
177
  */
196
178
  function hasDispatches(event) {
197
179
  return !!event._dispatchListeners;
@@ -210,8 +192,15 @@ var EventPluginUtils = {
210
192
  executeDispatchesInOrder: executeDispatchesInOrder,
211
193
  executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
212
194
  hasDispatches: hasDispatches,
213
- injection: injection,
214
- useTouchEvents: false
195
+
196
+ getNode: function (id) {
197
+ return injection.Mount.getNode(id);
198
+ },
199
+ getID: function (node) {
200
+ return injection.Mount.getID(node);
201
+ },
202
+
203
+ injection: injection
215
204
  };
216
205
 
217
- module.exports = EventPluginUtils;
206
+ module.exports = EventPluginUtils;