react 15.3.1-rc.2 → 15.4.0-rc.1

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 (190) hide show
  1. package/dist/react-with-addons.js +3961 -21387
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2701 -19464
  4. package/dist/react.min.js +2 -6
  5. package/lib/LinkedStateMixin.js +1 -2
  6. package/lib/PooledClass.js +3 -0
  7. package/lib/ReactAddonsDOMDependencies.js +36 -0
  8. package/lib/ReactAddonsDOMDependenciesUMDShim.js +32 -0
  9. package/lib/ReactCSSTransitionGroup.js +60 -42
  10. package/lib/ReactCSSTransitionGroupChild.js +2 -2
  11. package/lib/ReactClass.js +38 -53
  12. package/lib/ReactComponentTreeHook.js +84 -100
  13. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +5 -7
  14. package/lib/ReactCurrentOwner.js +1 -1
  15. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +6 -4
  16. package/lib/ReactElement.js +6 -29
  17. package/lib/ReactElementSymbol.js +20 -0
  18. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +4 -9
  19. package/lib/ReactElementValidator.js +1 -2
  20. package/lib/ReactPropTypeLocationNames.js +1 -0
  21. package/lib/ReactPropTypeLocations.js +2 -11
  22. package/lib/ReactPropTypes.js +30 -13
  23. package/lib/ReactPropTypesSecret.js +1 -0
  24. package/lib/ReactTransitionEvents.js +1 -1
  25. package/lib/ReactTransitionGroup.js +145 -141
  26. package/lib/ReactUMDEntry.js +11 -5
  27. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +4 -6
  28. package/lib/ReactVersion.js +1 -1
  29. package/lib/ReactWithAddons.js +15 -2
  30. package/lib/ReactWithAddonsUMDEntry.js +11 -5
  31. package/lib/canDefineProperty.js +2 -0
  32. package/lib/onlyChild.js +1 -1
  33. package/lib/traverseAllChildren.js +11 -2
  34. package/lib/update.js +6 -7
  35. package/package.json +2 -2
  36. package/lib/AutoFocusUtils.js +0 -24
  37. package/lib/BeforeInputEventPlugin.js +0 -388
  38. package/lib/CSSProperty.js +0 -148
  39. package/lib/CSSPropertyOperations.js +0 -205
  40. package/lib/CallbackQueue.js +0 -106
  41. package/lib/ChangeEventPlugin.js +0 -325
  42. package/lib/DOMChildrenOperations.js +0 -194
  43. package/lib/DOMLazyTree.js +0 -118
  44. package/lib/DOMProperty.js +0 -206
  45. package/lib/DOMPropertyOperations.js +0 -221
  46. package/lib/Danger.js +0 -48
  47. package/lib/DefaultEventPluginOrder.js +0 -27
  48. package/lib/DisabledInputUtils.js +0 -50
  49. package/lib/EnterLeaveEventPlugin.js +0 -105
  50. package/lib/EventConstants.js +0 -97
  51. package/lib/EventPluginHub.js +0 -251
  52. package/lib/EventPluginRegistry.js +0 -247
  53. package/lib/EventPluginUtils.js +0 -229
  54. package/lib/EventPropagators.js +0 -137
  55. package/lib/FallbackCompositionState.js +0 -95
  56. package/lib/HTMLDOMPropertyConfig.js +0 -209
  57. package/lib/LinkedValueUtils.js +0 -136
  58. package/lib/NativeMethodsMixin.js +0 -167
  59. package/lib/ReactBrowserEventEmitter.js +0 -317
  60. package/lib/ReactChildReconciler.js +0 -154
  61. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  62. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  63. package/lib/ReactComponentEnvironment.js +0 -45
  64. package/lib/ReactComponentTreeTestUtils.js +0 -87
  65. package/lib/ReactCompositeComponent.js +0 -920
  66. package/lib/ReactDOM.js +0 -110
  67. package/lib/ReactDOMButton.js +0 -24
  68. package/lib/ReactDOMComponent.js +0 -1005
  69. package/lib/ReactDOMComponentTree.js +0 -188
  70. package/lib/ReactDOMContainerInfo.js +0 -33
  71. package/lib/ReactDOMEmptyComponent.js +0 -60
  72. package/lib/ReactDOMFiber.js +0 -78
  73. package/lib/ReactDOMIDOperations.js +0 -34
  74. package/lib/ReactDOMInput.js +0 -269
  75. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  76. package/lib/ReactDOMOption.js +0 -123
  77. package/lib/ReactDOMSelect.js +0 -201
  78. package/lib/ReactDOMSelection.js +0 -212
  79. package/lib/ReactDOMServer.js +0 -26
  80. package/lib/ReactDOMTextComponent.js +0 -164
  81. package/lib/ReactDOMTextarea.js +0 -155
  82. package/lib/ReactDOMTreeTraversal.js +0 -136
  83. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  84. package/lib/ReactDebugTool.js +0 -307
  85. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  86. package/lib/ReactDefaultInjection.js +0 -84
  87. package/lib/ReactEmptyComponent.js +0 -30
  88. package/lib/ReactErrorUtils.js +0 -76
  89. package/lib/ReactEventEmitterMixin.js +0 -33
  90. package/lib/ReactEventListener.js +0 -157
  91. package/lib/ReactFeatureFlags.js +0 -22
  92. package/lib/ReactHostComponent.js +0 -76
  93. package/lib/ReactHostOperationHistoryHook.js +0 -37
  94. package/lib/ReactInjection.js +0 -36
  95. package/lib/ReactInputSelection.js +0 -124
  96. package/lib/ReactInstanceHandles.js +0 -302
  97. package/lib/ReactInstanceMap.js +0 -48
  98. package/lib/ReactInstrumentation.js +0 -21
  99. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  100. package/lib/ReactMarkupChecksum.js +0 -50
  101. package/lib/ReactMount.js +0 -495
  102. package/lib/ReactMultiChild.js +0 -451
  103. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  104. package/lib/ReactNative.js +0 -71
  105. package/lib/ReactNativeAttributePayload.js +0 -371
  106. package/lib/ReactNativeBaseComponent.js +0 -198
  107. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  108. package/lib/ReactNativeComponentEnvironment.js +0 -31
  109. package/lib/ReactNativeComponentTree.js +0 -68
  110. package/lib/ReactNativeContainerInfo.js +0 -21
  111. package/lib/ReactNativeDOMIDOperations.js +0 -79
  112. package/lib/ReactNativeDefaultInjection.js +0 -101
  113. package/lib/ReactNativeEventEmitter.js +0 -191
  114. package/lib/ReactNativeEventPluginOrder.js +0 -16
  115. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  116. package/lib/ReactNativeMount.js +0 -193
  117. package/lib/ReactNativePropRegistry.js +0 -52
  118. package/lib/ReactNativeReconcileTransaction.js +0 -116
  119. package/lib/ReactNativeTagHandles.js +0 -56
  120. package/lib/ReactNativeTextComponent.js +0 -71
  121. package/lib/ReactNativeTreeTraversal.js +0 -127
  122. package/lib/ReactNodeTypes.js +0 -40
  123. package/lib/ReactNoop.js +0 -173
  124. package/lib/ReactOwner.js +0 -94
  125. package/lib/ReactPerf.js +0 -494
  126. package/lib/ReactReconcileTransaction.js +0 -178
  127. package/lib/ReactReconciler.js +0 -168
  128. package/lib/ReactRef.js +0 -80
  129. package/lib/ReactServerBatchingStrategy.js +0 -22
  130. package/lib/ReactServerRendering.js +0 -90
  131. package/lib/ReactServerRenderingTransaction.js +0 -90
  132. package/lib/ReactServerUpdateQueue.js +0 -141
  133. package/lib/ReactSimpleEmptyComponent.js +0 -37
  134. package/lib/ReactTestMount.js +0 -123
  135. package/lib/ReactTestReconcileTransaction.js +0 -108
  136. package/lib/ReactTestRenderer.js +0 -144
  137. package/lib/ReactTestUtils.js +0 -518
  138. package/lib/ReactUpdateQueue.js +0 -226
  139. package/lib/ReactUpdates.js +0 -251
  140. package/lib/ResponderEventPlugin.js +0 -510
  141. package/lib/ResponderSyntheticEvent.js +0 -39
  142. package/lib/ResponderTouchHistoryStore.js +0 -184
  143. package/lib/SVGDOMPropertyConfig.js +0 -302
  144. package/lib/SelectEventPlugin.js +0 -196
  145. package/lib/SimpleEventPlugin.js +0 -635
  146. package/lib/SyntheticAnimationEvent.js +0 -39
  147. package/lib/SyntheticClipboardEvent.js +0 -38
  148. package/lib/SyntheticCompositionEvent.js +0 -36
  149. package/lib/SyntheticDragEvent.js +0 -36
  150. package/lib/SyntheticEvent.js +0 -267
  151. package/lib/SyntheticFocusEvent.js +0 -36
  152. package/lib/SyntheticInputEvent.js +0 -37
  153. package/lib/SyntheticKeyboardEvent.js +0 -84
  154. package/lib/SyntheticMouseEvent.js +0 -72
  155. package/lib/SyntheticTouchEvent.js +0 -45
  156. package/lib/SyntheticTransitionEvent.js +0 -39
  157. package/lib/SyntheticUIEvent.js +0 -59
  158. package/lib/SyntheticWheelEvent.js +0 -54
  159. package/lib/TapEventPlugin.js +0 -110
  160. package/lib/TouchHistoryMath.js +0 -99
  161. package/lib/Transaction.js +0 -233
  162. package/lib/ViewportMetrics.js +0 -27
  163. package/lib/accumulate.js +0 -46
  164. package/lib/accumulateInto.js +0 -58
  165. package/lib/adler32.js +0 -44
  166. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  167. package/lib/createReactNativeComponentClass.js +0 -42
  168. package/lib/dangerousStyleValue.js +0 -79
  169. package/lib/escapeTextContentForBrowser.js +0 -122
  170. package/lib/findDOMNode.js +0 -60
  171. package/lib/findNodeHandle.js +0 -91
  172. package/lib/forEachAccumulated.js +0 -31
  173. package/lib/getEventCharCode.js +0 -50
  174. package/lib/getEventKey.js +0 -102
  175. package/lib/getEventModifierState.js +0 -43
  176. package/lib/getEventTarget.js +0 -35
  177. package/lib/getHostComponentFromComposite.js +0 -30
  178. package/lib/getNodeForCharacterOffset.js +0 -74
  179. package/lib/getTestDocument.js +0 -21
  180. package/lib/getTextContentAccessor.js +0 -33
  181. package/lib/getVendorPrefixedEventName.js +0 -101
  182. package/lib/instantiateReactComponent.js +0 -119
  183. package/lib/isEventSupported.js +0 -60
  184. package/lib/isTextInputElement.js +0 -51
  185. package/lib/quoteAttributeValueForBrowser.js +0 -26
  186. package/lib/reactComponentExpect.js +0 -217
  187. package/lib/setInnerHTML.js +0 -98
  188. package/lib/setTextContent.js +0 -48
  189. package/lib/shouldUpdateReactComponent.js +0 -42
  190. package/lib/validateDOMNesting.js +0 -369
@@ -1,247 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule EventPluginRegistry
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant');
15
-
16
- var invariant = require('fbjs/lib/invariant');
17
-
18
- /**
19
- * Injectable ordering of event plugins.
20
- */
21
- var EventPluginOrder = null;
22
-
23
- /**
24
- * Injectable mapping from names to event plugin modules.
25
- */
26
- var namesToPlugins = {};
27
-
28
- /**
29
- * Recomputes the plugin list using the injected plugins and plugin ordering.
30
- *
31
- * @private
32
- */
33
- function recomputePluginOrdering() {
34
- if (!EventPluginOrder) {
35
- // Wait until an `EventPluginOrder` is injected.
36
- return;
37
- }
38
- for (var pluginName in namesToPlugins) {
39
- var PluginModule = namesToPlugins[pluginName];
40
- var pluginIndex = EventPluginOrder.indexOf(pluginName);
41
- !(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : _prodInvariant('96', pluginName) : void 0;
42
- if (EventPluginRegistry.plugins[pluginIndex]) {
43
- continue;
44
- }
45
- !PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : _prodInvariant('97', pluginName) : void 0;
46
- EventPluginRegistry.plugins[pluginIndex] = PluginModule;
47
- var publishedEvents = PluginModule.eventTypes;
48
- for (var eventName in publishedEvents) {
49
- !publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : _prodInvariant('98', eventName, pluginName) : void 0;
50
- }
51
- }
52
- }
53
-
54
- /**
55
- * Publishes an event so that it can be dispatched by the supplied plugin.
56
- *
57
- * @param {object} dispatchConfig Dispatch configuration for the event.
58
- * @param {object} PluginModule Plugin publishing the event.
59
- * @return {boolean} True if the event was successfully published.
60
- * @private
61
- */
62
- function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
63
- !!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : _prodInvariant('99', eventName) : void 0;
64
- EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
65
-
66
- var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
67
- if (phasedRegistrationNames) {
68
- for (var phaseName in phasedRegistrationNames) {
69
- if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
70
- var phasedRegistrationName = phasedRegistrationNames[phaseName];
71
- publishRegistrationName(phasedRegistrationName, PluginModule, eventName);
72
- }
73
- }
74
- return true;
75
- } else if (dispatchConfig.registrationName) {
76
- publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName);
77
- return true;
78
- }
79
- return false;
80
- }
81
-
82
- /**
83
- * Publishes a registration name that is used to identify dispatched events and
84
- * can be used with `EventPluginHub.putListener` to register listeners.
85
- *
86
- * @param {string} registrationName Registration name to add.
87
- * @param {object} PluginModule Plugin publishing the event.
88
- * @private
89
- */
90
- function publishRegistrationName(registrationName, PluginModule, eventName) {
91
- !!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : _prodInvariant('100', registrationName) : void 0;
92
- EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
93
- EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
94
-
95
- if (process.env.NODE_ENV !== 'production') {
96
- var lowerCasedName = registrationName.toLowerCase();
97
- EventPluginRegistry.possibleRegistrationNames[lowerCasedName] = registrationName;
98
-
99
- if (registrationName === 'onDoubleClick') {
100
- EventPluginRegistry.possibleRegistrationNames.ondblclick = registrationName;
101
- }
102
- }
103
- }
104
-
105
- /**
106
- * Registers plugins so that they can extract and dispatch events.
107
- *
108
- * @see {EventPluginHub}
109
- */
110
- var EventPluginRegistry = {
111
-
112
- /**
113
- * Ordered list of injected plugins.
114
- */
115
- plugins: [],
116
-
117
- /**
118
- * Mapping from event name to dispatch config
119
- */
120
- eventNameDispatchConfigs: {},
121
-
122
- /**
123
- * Mapping from registration name to plugin module
124
- */
125
- registrationNameModules: {},
126
-
127
- /**
128
- * Mapping from registration name to event name
129
- */
130
- registrationNameDependencies: {},
131
-
132
- /**
133
- * Mapping from lowercase registration names to the properly cased version,
134
- * used to warn in the case of missing event handlers. Available
135
- * only in __DEV__.
136
- * @type {Object}
137
- */
138
- possibleRegistrationNames: process.env.NODE_ENV !== 'production' ? {} : null,
139
-
140
- /**
141
- * Injects an ordering of plugins (by plugin name). This allows the ordering
142
- * to be decoupled from injection of the actual plugins so that ordering is
143
- * always deterministic regardless of packaging, on-the-fly injection, etc.
144
- *
145
- * @param {array} InjectedEventPluginOrder
146
- * @internal
147
- * @see {EventPluginHub.injection.injectEventPluginOrder}
148
- */
149
- injectEventPluginOrder: function (InjectedEventPluginOrder) {
150
- !!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : _prodInvariant('101') : void 0;
151
- // Clone the ordering so it cannot be dynamically mutated.
152
- EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
153
- recomputePluginOrdering();
154
- },
155
-
156
- /**
157
- * Injects plugins to be used by `EventPluginHub`. The plugin names must be
158
- * in the ordering injected by `injectEventPluginOrder`.
159
- *
160
- * Plugins can be injected as part of page initialization or on-the-fly.
161
- *
162
- * @param {object} injectedNamesToPlugins Map from names to plugin modules.
163
- * @internal
164
- * @see {EventPluginHub.injection.injectEventPluginsByName}
165
- */
166
- injectEventPluginsByName: function (injectedNamesToPlugins) {
167
- var isOrderingDirty = false;
168
- for (var pluginName in injectedNamesToPlugins) {
169
- if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
170
- continue;
171
- }
172
- var PluginModule = injectedNamesToPlugins[pluginName];
173
- if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
174
- !!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.', pluginName) : _prodInvariant('102', pluginName) : void 0;
175
- namesToPlugins[pluginName] = PluginModule;
176
- isOrderingDirty = true;
177
- }
178
- }
179
- if (isOrderingDirty) {
180
- recomputePluginOrdering();
181
- }
182
- },
183
-
184
- /**
185
- * Looks up the plugin for the supplied event.
186
- *
187
- * @param {object} event A synthetic event.
188
- * @return {?object} The plugin that created the supplied event.
189
- * @internal
190
- */
191
- getPluginModuleForEvent: function (event) {
192
- var dispatchConfig = event.dispatchConfig;
193
- if (dispatchConfig.registrationName) {
194
- return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
195
- }
196
- for (var phase in dispatchConfig.phasedRegistrationNames) {
197
- if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
198
- continue;
199
- }
200
- var PluginModule = EventPluginRegistry.registrationNameModules[dispatchConfig.phasedRegistrationNames[phase]];
201
- if (PluginModule) {
202
- return PluginModule;
203
- }
204
- }
205
- return null;
206
- },
207
-
208
- /**
209
- * Exposed for unit testing.
210
- * @private
211
- */
212
- _resetEventPlugins: function () {
213
- EventPluginOrder = null;
214
- for (var pluginName in namesToPlugins) {
215
- if (namesToPlugins.hasOwnProperty(pluginName)) {
216
- delete namesToPlugins[pluginName];
217
- }
218
- }
219
- EventPluginRegistry.plugins.length = 0;
220
-
221
- var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
222
- for (var eventName in eventNameDispatchConfigs) {
223
- if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
224
- delete eventNameDispatchConfigs[eventName];
225
- }
226
- }
227
-
228
- var registrationNameModules = EventPluginRegistry.registrationNameModules;
229
- for (var registrationName in registrationNameModules) {
230
- if (registrationNameModules.hasOwnProperty(registrationName)) {
231
- delete registrationNameModules[registrationName];
232
- }
233
- }
234
-
235
- if (process.env.NODE_ENV !== 'production') {
236
- var possibleRegistrationNames = EventPluginRegistry.possibleRegistrationNames;
237
- for (var lowerCasedName in possibleRegistrationNames) {
238
- if (possibleRegistrationNames.hasOwnProperty(lowerCasedName)) {
239
- delete possibleRegistrationNames[lowerCasedName];
240
- }
241
- }
242
- }
243
- }
244
-
245
- };
246
-
247
- module.exports = EventPluginRegistry;
@@ -1,229 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule EventPluginUtils
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant');
15
-
16
- var EventConstants = require('./EventConstants');
17
- var ReactErrorUtils = require('./ReactErrorUtils');
18
-
19
- var invariant = require('fbjs/lib/invariant');
20
- var warning = require('fbjs/lib/warning');
21
-
22
- /**
23
- * Injected dependencies:
24
- */
25
-
26
- /**
27
- * - `ComponentTree`: [required] Module that can convert between React instances
28
- * and actual node references.
29
- */
30
- var ComponentTree;
31
- var TreeTraversal;
32
- var injection = {
33
- injectComponentTree: function (Injected) {
34
- ComponentTree = Injected;
35
- if (process.env.NODE_ENV !== 'production') {
36
- process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
37
- }
38
- },
39
- injectTreeTraversal: function (Injected) {
40
- TreeTraversal = Injected;
41
- if (process.env.NODE_ENV !== 'production') {
42
- process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.isAncestor && Injected.getLowestCommonAncestor, 'EventPluginUtils.injection.injectTreeTraversal(...): Injected ' + 'module is missing isAncestor or getLowestCommonAncestor.') : void 0;
43
- }
44
- }
45
- };
46
-
47
- var topLevelTypes = EventConstants.topLevelTypes;
48
-
49
- function isEndish(topLevelType) {
50
- return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel;
51
- }
52
-
53
- function isMoveish(topLevelType) {
54
- return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove;
55
- }
56
- function isStartish(topLevelType) {
57
- return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart;
58
- }
59
-
60
- var validateEventDispatches;
61
- if (process.env.NODE_ENV !== 'production') {
62
- validateEventDispatches = function (event) {
63
- var dispatchListeners = event._dispatchListeners;
64
- var dispatchInstances = event._dispatchInstances;
65
-
66
- var listenersIsArr = Array.isArray(dispatchListeners);
67
- var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
68
-
69
- var instancesIsArr = Array.isArray(dispatchInstances);
70
- var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
71
-
72
- process.env.NODE_ENV !== 'production' ? warning(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : void 0;
73
- };
74
- }
75
-
76
- /**
77
- * Dispatch the event to the listener.
78
- * @param {SyntheticEvent} event SyntheticEvent to handle
79
- * @param {boolean} simulated If the event is simulated (changes exn behavior)
80
- * @param {function} listener Application-level callback
81
- * @param {*} inst Internal component instance
82
- */
83
- function executeDispatch(event, simulated, listener, inst) {
84
- var type = event.type || 'unknown-event';
85
- event.currentTarget = EventPluginUtils.getNodeFromInstance(inst);
86
- if (simulated) {
87
- ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event);
88
- } else {
89
- ReactErrorUtils.invokeGuardedCallback(type, listener, event);
90
- }
91
- event.currentTarget = null;
92
- }
93
-
94
- /**
95
- * Standard/simple iteration through an event's collected dispatches.
96
- */
97
- function executeDispatchesInOrder(event, simulated) {
98
- var dispatchListeners = event._dispatchListeners;
99
- var dispatchInstances = event._dispatchInstances;
100
- if (process.env.NODE_ENV !== 'production') {
101
- validateEventDispatches(event);
102
- }
103
- if (Array.isArray(dispatchListeners)) {
104
- for (var i = 0; i < dispatchListeners.length; i++) {
105
- if (event.isPropagationStopped()) {
106
- break;
107
- }
108
- // Listeners and Instances are two parallel arrays that are always in sync.
109
- executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]);
110
- }
111
- } else if (dispatchListeners) {
112
- executeDispatch(event, simulated, dispatchListeners, dispatchInstances);
113
- }
114
- event._dispatchListeners = null;
115
- event._dispatchInstances = null;
116
- }
117
-
118
- /**
119
- * Standard/simple iteration through an event's collected dispatches, but stops
120
- * at the first dispatch execution returning true, and returns that id.
121
- *
122
- * @return {?string} id of the first dispatch execution who's listener returns
123
- * true, or null if no listener returned true.
124
- */
125
- function executeDispatchesInOrderStopAtTrueImpl(event) {
126
- var dispatchListeners = event._dispatchListeners;
127
- var dispatchInstances = event._dispatchInstances;
128
- if (process.env.NODE_ENV !== 'production') {
129
- validateEventDispatches(event);
130
- }
131
- if (Array.isArray(dispatchListeners)) {
132
- for (var i = 0; i < dispatchListeners.length; i++) {
133
- if (event.isPropagationStopped()) {
134
- break;
135
- }
136
- // Listeners and Instances are two parallel arrays that are always in sync.
137
- if (dispatchListeners[i](event, dispatchInstances[i])) {
138
- return dispatchInstances[i];
139
- }
140
- }
141
- } else if (dispatchListeners) {
142
- if (dispatchListeners(event, dispatchInstances)) {
143
- return dispatchInstances;
144
- }
145
- }
146
- return null;
147
- }
148
-
149
- /**
150
- * @see executeDispatchesInOrderStopAtTrueImpl
151
- */
152
- function executeDispatchesInOrderStopAtTrue(event) {
153
- var ret = executeDispatchesInOrderStopAtTrueImpl(event);
154
- event._dispatchInstances = null;
155
- event._dispatchListeners = null;
156
- return ret;
157
- }
158
-
159
- /**
160
- * Execution of a "direct" dispatch - there must be at most one dispatch
161
- * accumulated on the event or it is considered an error. It doesn't really make
162
- * sense for an event with multiple dispatches (bubbled) to keep track of the
163
- * return values at each dispatch execution, but it does tend to make sense when
164
- * dealing with "direct" dispatches.
165
- *
166
- * @return {*} The return value of executing the single dispatch.
167
- */
168
- function executeDirectDispatch(event) {
169
- if (process.env.NODE_ENV !== 'production') {
170
- validateEventDispatches(event);
171
- }
172
- var dispatchListener = event._dispatchListeners;
173
- var dispatchInstance = event._dispatchInstances;
174
- !!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : _prodInvariant('103') : void 0;
175
- event.currentTarget = dispatchListener ? EventPluginUtils.getNodeFromInstance(dispatchInstance) : null;
176
- var res = dispatchListener ? dispatchListener(event) : null;
177
- event.currentTarget = null;
178
- event._dispatchListeners = null;
179
- event._dispatchInstances = null;
180
- return res;
181
- }
182
-
183
- /**
184
- * @param {SyntheticEvent} event
185
- * @return {boolean} True iff number of dispatches accumulated is greater than 0.
186
- */
187
- function hasDispatches(event) {
188
- return !!event._dispatchListeners;
189
- }
190
-
191
- /**
192
- * General utilities that are useful in creating custom Event Plugins.
193
- */
194
- var EventPluginUtils = {
195
- isEndish: isEndish,
196
- isMoveish: isMoveish,
197
- isStartish: isStartish,
198
-
199
- executeDirectDispatch: executeDirectDispatch,
200
- executeDispatchesInOrder: executeDispatchesInOrder,
201
- executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
202
- hasDispatches: hasDispatches,
203
-
204
- getInstanceFromNode: function (node) {
205
- return ComponentTree.getInstanceFromNode(node);
206
- },
207
- getNodeFromInstance: function (node) {
208
- return ComponentTree.getNodeFromInstance(node);
209
- },
210
- isAncestor: function (a, b) {
211
- return TreeTraversal.isAncestor(a, b);
212
- },
213
- getLowestCommonAncestor: function (a, b) {
214
- return TreeTraversal.getLowestCommonAncestor(a, b);
215
- },
216
- getParentInstance: function (inst) {
217
- return TreeTraversal.getParentInstance(inst);
218
- },
219
- traverseTwoPhase: function (target, fn, arg) {
220
- return TreeTraversal.traverseTwoPhase(target, fn, arg);
221
- },
222
- traverseEnterLeave: function (from, to, fn, argFrom, argTo) {
223
- return TreeTraversal.traverseEnterLeave(from, to, fn, argFrom, argTo);
224
- },
225
-
226
- injection: injection
227
- };
228
-
229
- module.exports = EventPluginUtils;