react 15.3.2 → 15.4.0-rc.4

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 (210) hide show
  1. package/dist/react-with-addons.js +3864 -21390
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2639 -19486
  4. package/dist/react.min.js +2 -6
  5. package/lib/KeyEscapeUtils.js +0 -1
  6. package/lib/LinkedStateMixin.js +1 -3
  7. package/lib/PooledClass.js +3 -1
  8. package/lib/React.js +0 -1
  9. package/lib/ReactAddonsDOMDependencies.js +35 -0
  10. package/lib/ReactAddonsDOMDependenciesUMDShim.js +31 -0
  11. package/lib/ReactCSSTransitionGroup.js +60 -43
  12. package/lib/ReactCSSTransitionGroupChild.js +2 -3
  13. package/lib/ReactChildren.js +0 -1
  14. package/lib/ReactClass.js +38 -54
  15. package/lib/ReactComponent.js +0 -1
  16. package/lib/ReactComponentTreeDevtool.js +0 -1
  17. package/lib/ReactComponentTreeHook.js +84 -101
  18. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +4 -7
  19. package/lib/ReactComponentWithPureRenderMixin.js +0 -1
  20. package/lib/ReactCurrentOwner.js +1 -2
  21. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +5 -4
  22. package/lib/ReactDOMFactories.js +0 -1
  23. package/lib/ReactElement.js +6 -14
  24. package/lib/ReactElementSymbol.js +19 -0
  25. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +3 -9
  26. package/lib/ReactElementValidator.js +1 -3
  27. package/lib/ReactFragment.js +0 -1
  28. package/lib/ReactLink.js +0 -1
  29. package/lib/ReactNoopUpdateQueue.js +0 -1
  30. package/lib/ReactPropTypeLocationNames.js +1 -1
  31. package/lib/ReactPropTypeLocations.js +2 -12
  32. package/lib/ReactPropTypes.js +5 -3
  33. package/lib/ReactPropTypesSecret.js +1 -1
  34. package/lib/ReactPureComponent.js +0 -1
  35. package/lib/ReactStateSetters.js +0 -1
  36. package/lib/ReactTransitionChildMapping.js +0 -1
  37. package/lib/ReactTransitionEvents.js +1 -2
  38. package/lib/ReactTransitionGroup.js +145 -142
  39. package/lib/ReactUMDEntry.js +11 -6
  40. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +3 -6
  41. package/lib/ReactVersion.js +1 -2
  42. package/lib/ReactWithAddons.js +15 -3
  43. package/lib/ReactWithAddonsUMDEntry.js +11 -6
  44. package/lib/canDefineProperty.js +2 -1
  45. package/lib/checkReactTypeSpec.js +0 -1
  46. package/lib/deprecated.js +0 -1
  47. package/lib/flattenChildren.js +0 -1
  48. package/lib/getIteratorFn.js +0 -1
  49. package/lib/onlyChild.js +0 -1
  50. package/lib/reactProdInvariant.js +0 -1
  51. package/lib/shallowCompare.js +1 -2
  52. package/lib/sliceChildren.js +0 -1
  53. package/lib/traverseAllChildren.js +11 -3
  54. package/lib/update.js +6 -8
  55. package/package.json +1 -1
  56. package/lib/AutoFocusUtils.js +0 -24
  57. package/lib/BeforeInputEventPlugin.js +0 -390
  58. package/lib/CSSProperty.js +0 -148
  59. package/lib/CSSPropertyOperations.js +0 -205
  60. package/lib/CallbackQueue.js +0 -106
  61. package/lib/ChangeEventPlugin.js +0 -325
  62. package/lib/DOMChildrenOperations.js +0 -194
  63. package/lib/DOMLazyTree.js +0 -118
  64. package/lib/DOMProperty.js +0 -206
  65. package/lib/DOMPropertyOperations.js +0 -221
  66. package/lib/Danger.js +0 -48
  67. package/lib/DefaultEventPluginOrder.js +0 -27
  68. package/lib/DisabledInputUtils.js +0 -50
  69. package/lib/EnterLeaveEventPlugin.js +0 -105
  70. package/lib/EventConstants.js +0 -97
  71. package/lib/EventPluginHub.js +0 -251
  72. package/lib/EventPluginRegistry.js +0 -247
  73. package/lib/EventPluginUtils.js +0 -229
  74. package/lib/EventPropagators.js +0 -137
  75. package/lib/FallbackCompositionState.js +0 -95
  76. package/lib/HTMLDOMPropertyConfig.js +0 -212
  77. package/lib/LinkedValueUtils.js +0 -136
  78. package/lib/NativeMethodsMixin.js +0 -167
  79. package/lib/ReactBrowserEventEmitter.js +0 -330
  80. package/lib/ReactChildReconciler.js +0 -154
  81. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  82. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  83. package/lib/ReactComponentEnvironment.js +0 -45
  84. package/lib/ReactComponentTreeTestUtils.js +0 -87
  85. package/lib/ReactCompositeComponent.js +0 -904
  86. package/lib/ReactDOM.js +0 -110
  87. package/lib/ReactDOMButton.js +0 -24
  88. package/lib/ReactDOMComponent.js +0 -1006
  89. package/lib/ReactDOMComponentTree.js +0 -188
  90. package/lib/ReactDOMContainerInfo.js +0 -33
  91. package/lib/ReactDOMEmptyComponent.js +0 -60
  92. package/lib/ReactDOMFiber.js +0 -76
  93. package/lib/ReactDOMIDOperations.js +0 -34
  94. package/lib/ReactDOMInput.js +0 -269
  95. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  96. package/lib/ReactDOMOption.js +0 -123
  97. package/lib/ReactDOMSelect.js +0 -201
  98. package/lib/ReactDOMSelection.js +0 -212
  99. package/lib/ReactDOMServer.js +0 -26
  100. package/lib/ReactDOMTextComponent.js +0 -164
  101. package/lib/ReactDOMTextarea.js +0 -155
  102. package/lib/ReactDOMTreeTraversal.js +0 -136
  103. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  104. package/lib/ReactDebugTool.js +0 -301
  105. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  106. package/lib/ReactDefaultInjection.js +0 -84
  107. package/lib/ReactEmptyComponent.js +0 -30
  108. package/lib/ReactErrorUtils.js +0 -76
  109. package/lib/ReactEventEmitterMixin.js +0 -33
  110. package/lib/ReactEventListener.js +0 -157
  111. package/lib/ReactFeatureFlags.js +0 -22
  112. package/lib/ReactHostComponent.js +0 -76
  113. package/lib/ReactHostOperationHistoryHook.js +0 -37
  114. package/lib/ReactInjection.js +0 -36
  115. package/lib/ReactInputSelection.js +0 -124
  116. package/lib/ReactInstanceHandles.js +0 -302
  117. package/lib/ReactInstanceMap.js +0 -48
  118. package/lib/ReactInstrumentation.js +0 -21
  119. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  120. package/lib/ReactMarkupChecksum.js +0 -50
  121. package/lib/ReactMount.js +0 -534
  122. package/lib/ReactMultiChild.js +0 -451
  123. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  124. package/lib/ReactNative.js +0 -71
  125. package/lib/ReactNativeAttributePayload.js +0 -371
  126. package/lib/ReactNativeBaseComponent.js +0 -198
  127. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  128. package/lib/ReactNativeComponentEnvironment.js +0 -31
  129. package/lib/ReactNativeComponentTree.js +0 -68
  130. package/lib/ReactNativeContainerInfo.js +0 -21
  131. package/lib/ReactNativeDOMIDOperations.js +0 -79
  132. package/lib/ReactNativeDefaultInjection.js +0 -101
  133. package/lib/ReactNativeEventEmitter.js +0 -191
  134. package/lib/ReactNativeEventPluginOrder.js +0 -16
  135. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  136. package/lib/ReactNativeMount.js +0 -193
  137. package/lib/ReactNativePropRegistry.js +0 -52
  138. package/lib/ReactNativeReconcileTransaction.js +0 -129
  139. package/lib/ReactNativeTagHandles.js +0 -56
  140. package/lib/ReactNativeTextComponent.js +0 -71
  141. package/lib/ReactNativeTreeTraversal.js +0 -127
  142. package/lib/ReactNodeTypes.js +0 -40
  143. package/lib/ReactNoop.js +0 -173
  144. package/lib/ReactOwner.js +0 -94
  145. package/lib/ReactPerf.js +0 -494
  146. package/lib/ReactReconcileTransaction.js +0 -178
  147. package/lib/ReactReconciler.js +0 -168
  148. package/lib/ReactRef.js +0 -80
  149. package/lib/ReactServerBatchingStrategy.js +0 -22
  150. package/lib/ReactServerRendering.js +0 -90
  151. package/lib/ReactServerRenderingTransaction.js +0 -90
  152. package/lib/ReactServerUpdateQueue.js +0 -141
  153. package/lib/ReactSimpleEmptyComponent.js +0 -37
  154. package/lib/ReactTestMount.js +0 -126
  155. package/lib/ReactTestReconcileTransaction.js +0 -121
  156. package/lib/ReactTestRenderer.js +0 -144
  157. package/lib/ReactTestUtils.js +0 -518
  158. package/lib/ReactUpdateQueue.js +0 -226
  159. package/lib/ReactUpdates.js +0 -251
  160. package/lib/ResponderEventPlugin.js +0 -510
  161. package/lib/ResponderSyntheticEvent.js +0 -39
  162. package/lib/ResponderTouchHistoryStore.js +0 -184
  163. package/lib/SVGDOMPropertyConfig.js +0 -302
  164. package/lib/SelectEventPlugin.js +0 -196
  165. package/lib/SimpleEventPlugin.js +0 -635
  166. package/lib/SyntheticAnimationEvent.js +0 -39
  167. package/lib/SyntheticClipboardEvent.js +0 -38
  168. package/lib/SyntheticCompositionEvent.js +0 -36
  169. package/lib/SyntheticDragEvent.js +0 -36
  170. package/lib/SyntheticEvent.js +0 -268
  171. package/lib/SyntheticFocusEvent.js +0 -36
  172. package/lib/SyntheticInputEvent.js +0 -37
  173. package/lib/SyntheticKeyboardEvent.js +0 -84
  174. package/lib/SyntheticMouseEvent.js +0 -72
  175. package/lib/SyntheticTouchEvent.js +0 -45
  176. package/lib/SyntheticTransitionEvent.js +0 -39
  177. package/lib/SyntheticUIEvent.js +0 -59
  178. package/lib/SyntheticWheelEvent.js +0 -54
  179. package/lib/TapEventPlugin.js +0 -110
  180. package/lib/TouchHistoryMath.js +0 -99
  181. package/lib/Transaction.js +0 -233
  182. package/lib/ViewportMetrics.js +0 -27
  183. package/lib/accumulate.js +0 -46
  184. package/lib/accumulateInto.js +0 -58
  185. package/lib/adler32.js +0 -44
  186. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  187. package/lib/createReactNativeComponentClass.js +0 -42
  188. package/lib/dangerousStyleValue.js +0 -79
  189. package/lib/escapeTextContentForBrowser.js +0 -123
  190. package/lib/findDOMNode.js +0 -60
  191. package/lib/findNodeHandle.js +0 -91
  192. package/lib/forEachAccumulated.js +0 -31
  193. package/lib/getEventCharCode.js +0 -50
  194. package/lib/getEventKey.js +0 -102
  195. package/lib/getEventModifierState.js +0 -43
  196. package/lib/getEventTarget.js +0 -35
  197. package/lib/getHostComponentFromComposite.js +0 -30
  198. package/lib/getNodeForCharacterOffset.js +0 -74
  199. package/lib/getTestDocument.js +0 -21
  200. package/lib/getTextContentAccessor.js +0 -33
  201. package/lib/getVendorPrefixedEventName.js +0 -101
  202. package/lib/instantiateReactComponent.js +0 -119
  203. package/lib/isEventSupported.js +0 -60
  204. package/lib/isTextInputElement.js +0 -51
  205. package/lib/quoteAttributeValueForBrowser.js +0 -26
  206. package/lib/reactComponentExpect.js +0 -217
  207. package/lib/setInnerHTML.js +0 -98
  208. package/lib/setTextContent.js +0 -48
  209. package/lib/shouldUpdateReactComponent.js +0 -42
  210. package/lib/validateDOMNesting.js +0 -382
@@ -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;