react 15.3.2-rc.1 → 15.4.0-rc.3

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 (209) hide show
  1. package/dist/react-with-addons.js +3863 -21388
  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/sliceChildren.js +0 -1
  52. package/lib/traverseAllChildren.js +11 -3
  53. package/lib/update.js +6 -8
  54. package/package.json +1 -1
  55. package/lib/AutoFocusUtils.js +0 -24
  56. package/lib/BeforeInputEventPlugin.js +0 -390
  57. package/lib/CSSProperty.js +0 -148
  58. package/lib/CSSPropertyOperations.js +0 -205
  59. package/lib/CallbackQueue.js +0 -106
  60. package/lib/ChangeEventPlugin.js +0 -325
  61. package/lib/DOMChildrenOperations.js +0 -194
  62. package/lib/DOMLazyTree.js +0 -118
  63. package/lib/DOMProperty.js +0 -206
  64. package/lib/DOMPropertyOperations.js +0 -221
  65. package/lib/Danger.js +0 -48
  66. package/lib/DefaultEventPluginOrder.js +0 -27
  67. package/lib/DisabledInputUtils.js +0 -50
  68. package/lib/EnterLeaveEventPlugin.js +0 -105
  69. package/lib/EventConstants.js +0 -97
  70. package/lib/EventPluginHub.js +0 -251
  71. package/lib/EventPluginRegistry.js +0 -247
  72. package/lib/EventPluginUtils.js +0 -229
  73. package/lib/EventPropagators.js +0 -137
  74. package/lib/FallbackCompositionState.js +0 -95
  75. package/lib/HTMLDOMPropertyConfig.js +0 -212
  76. package/lib/LinkedValueUtils.js +0 -136
  77. package/lib/NativeMethodsMixin.js +0 -167
  78. package/lib/ReactBrowserEventEmitter.js +0 -330
  79. package/lib/ReactChildReconciler.js +0 -154
  80. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  81. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  82. package/lib/ReactComponentEnvironment.js +0 -45
  83. package/lib/ReactComponentTreeTestUtils.js +0 -87
  84. package/lib/ReactCompositeComponent.js +0 -904
  85. package/lib/ReactDOM.js +0 -110
  86. package/lib/ReactDOMButton.js +0 -24
  87. package/lib/ReactDOMComponent.js +0 -1006
  88. package/lib/ReactDOMComponentTree.js +0 -188
  89. package/lib/ReactDOMContainerInfo.js +0 -33
  90. package/lib/ReactDOMEmptyComponent.js +0 -60
  91. package/lib/ReactDOMFiber.js +0 -76
  92. package/lib/ReactDOMIDOperations.js +0 -34
  93. package/lib/ReactDOMInput.js +0 -269
  94. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  95. package/lib/ReactDOMOption.js +0 -123
  96. package/lib/ReactDOMSelect.js +0 -201
  97. package/lib/ReactDOMSelection.js +0 -212
  98. package/lib/ReactDOMServer.js +0 -26
  99. package/lib/ReactDOMTextComponent.js +0 -164
  100. package/lib/ReactDOMTextarea.js +0 -155
  101. package/lib/ReactDOMTreeTraversal.js +0 -136
  102. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  103. package/lib/ReactDebugTool.js +0 -301
  104. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  105. package/lib/ReactDefaultInjection.js +0 -84
  106. package/lib/ReactEmptyComponent.js +0 -30
  107. package/lib/ReactErrorUtils.js +0 -76
  108. package/lib/ReactEventEmitterMixin.js +0 -33
  109. package/lib/ReactEventListener.js +0 -157
  110. package/lib/ReactFeatureFlags.js +0 -22
  111. package/lib/ReactHostComponent.js +0 -76
  112. package/lib/ReactHostOperationHistoryHook.js +0 -37
  113. package/lib/ReactInjection.js +0 -36
  114. package/lib/ReactInputSelection.js +0 -124
  115. package/lib/ReactInstanceHandles.js +0 -302
  116. package/lib/ReactInstanceMap.js +0 -48
  117. package/lib/ReactInstrumentation.js +0 -21
  118. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  119. package/lib/ReactMarkupChecksum.js +0 -50
  120. package/lib/ReactMount.js +0 -534
  121. package/lib/ReactMultiChild.js +0 -451
  122. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  123. package/lib/ReactNative.js +0 -71
  124. package/lib/ReactNativeAttributePayload.js +0 -371
  125. package/lib/ReactNativeBaseComponent.js +0 -198
  126. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  127. package/lib/ReactNativeComponentEnvironment.js +0 -31
  128. package/lib/ReactNativeComponentTree.js +0 -68
  129. package/lib/ReactNativeContainerInfo.js +0 -21
  130. package/lib/ReactNativeDOMIDOperations.js +0 -79
  131. package/lib/ReactNativeDefaultInjection.js +0 -101
  132. package/lib/ReactNativeEventEmitter.js +0 -191
  133. package/lib/ReactNativeEventPluginOrder.js +0 -16
  134. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  135. package/lib/ReactNativeMount.js +0 -193
  136. package/lib/ReactNativePropRegistry.js +0 -52
  137. package/lib/ReactNativeReconcileTransaction.js +0 -129
  138. package/lib/ReactNativeTagHandles.js +0 -56
  139. package/lib/ReactNativeTextComponent.js +0 -71
  140. package/lib/ReactNativeTreeTraversal.js +0 -127
  141. package/lib/ReactNodeTypes.js +0 -40
  142. package/lib/ReactNoop.js +0 -173
  143. package/lib/ReactOwner.js +0 -94
  144. package/lib/ReactPerf.js +0 -494
  145. package/lib/ReactReconcileTransaction.js +0 -178
  146. package/lib/ReactReconciler.js +0 -168
  147. package/lib/ReactRef.js +0 -80
  148. package/lib/ReactServerBatchingStrategy.js +0 -22
  149. package/lib/ReactServerRendering.js +0 -90
  150. package/lib/ReactServerRenderingTransaction.js +0 -90
  151. package/lib/ReactServerUpdateQueue.js +0 -141
  152. package/lib/ReactSimpleEmptyComponent.js +0 -37
  153. package/lib/ReactTestMount.js +0 -126
  154. package/lib/ReactTestReconcileTransaction.js +0 -121
  155. package/lib/ReactTestRenderer.js +0 -144
  156. package/lib/ReactTestUtils.js +0 -518
  157. package/lib/ReactUpdateQueue.js +0 -226
  158. package/lib/ReactUpdates.js +0 -251
  159. package/lib/ResponderEventPlugin.js +0 -510
  160. package/lib/ResponderSyntheticEvent.js +0 -39
  161. package/lib/ResponderTouchHistoryStore.js +0 -184
  162. package/lib/SVGDOMPropertyConfig.js +0 -302
  163. package/lib/SelectEventPlugin.js +0 -196
  164. package/lib/SimpleEventPlugin.js +0 -635
  165. package/lib/SyntheticAnimationEvent.js +0 -39
  166. package/lib/SyntheticClipboardEvent.js +0 -38
  167. package/lib/SyntheticCompositionEvent.js +0 -36
  168. package/lib/SyntheticDragEvent.js +0 -36
  169. package/lib/SyntheticEvent.js +0 -268
  170. package/lib/SyntheticFocusEvent.js +0 -36
  171. package/lib/SyntheticInputEvent.js +0 -37
  172. package/lib/SyntheticKeyboardEvent.js +0 -84
  173. package/lib/SyntheticMouseEvent.js +0 -72
  174. package/lib/SyntheticTouchEvent.js +0 -45
  175. package/lib/SyntheticTransitionEvent.js +0 -39
  176. package/lib/SyntheticUIEvent.js +0 -59
  177. package/lib/SyntheticWheelEvent.js +0 -54
  178. package/lib/TapEventPlugin.js +0 -110
  179. package/lib/TouchHistoryMath.js +0 -99
  180. package/lib/Transaction.js +0 -233
  181. package/lib/ViewportMetrics.js +0 -27
  182. package/lib/accumulate.js +0 -46
  183. package/lib/accumulateInto.js +0 -58
  184. package/lib/adler32.js +0 -44
  185. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  186. package/lib/createReactNativeComponentClass.js +0 -42
  187. package/lib/dangerousStyleValue.js +0 -79
  188. package/lib/escapeTextContentForBrowser.js +0 -123
  189. package/lib/findDOMNode.js +0 -60
  190. package/lib/findNodeHandle.js +0 -91
  191. package/lib/forEachAccumulated.js +0 -31
  192. package/lib/getEventCharCode.js +0 -50
  193. package/lib/getEventKey.js +0 -102
  194. package/lib/getEventModifierState.js +0 -43
  195. package/lib/getEventTarget.js +0 -35
  196. package/lib/getHostComponentFromComposite.js +0 -30
  197. package/lib/getNodeForCharacterOffset.js +0 -74
  198. package/lib/getTestDocument.js +0 -21
  199. package/lib/getTextContentAccessor.js +0 -33
  200. package/lib/getVendorPrefixedEventName.js +0 -101
  201. package/lib/instantiateReactComponent.js +0 -119
  202. package/lib/isEventSupported.js +0 -60
  203. package/lib/isTextInputElement.js +0 -51
  204. package/lib/quoteAttributeValueForBrowser.js +0 -26
  205. package/lib/reactComponentExpect.js +0 -217
  206. package/lib/setInnerHTML.js +0 -98
  207. package/lib/setTextContent.js +0 -48
  208. package/lib/shouldUpdateReactComponent.js +0 -42
  209. package/lib/validateDOMNesting.js +0 -382
@@ -1,510 +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 ResponderEventPlugin
10
- */
11
-
12
- 'use strict';
13
-
14
- var EventConstants = require('./EventConstants');
15
- var EventPluginUtils = require('./EventPluginUtils');
16
- var EventPropagators = require('./EventPropagators');
17
- var ResponderSyntheticEvent = require('./ResponderSyntheticEvent');
18
- var ResponderTouchHistoryStore = require('./ResponderTouchHistoryStore');
19
-
20
- var accumulate = require('./accumulate');
21
- var keyOf = require('fbjs/lib/keyOf');
22
-
23
- var isStartish = EventPluginUtils.isStartish;
24
- var isMoveish = EventPluginUtils.isMoveish;
25
- var isEndish = EventPluginUtils.isEndish;
26
- var executeDirectDispatch = EventPluginUtils.executeDirectDispatch;
27
- var hasDispatches = EventPluginUtils.hasDispatches;
28
- var executeDispatchesInOrderStopAtTrue = EventPluginUtils.executeDispatchesInOrderStopAtTrue;
29
-
30
- /**
31
- * Instance of element that should respond to touch/move types of interactions,
32
- * as indicated explicitly by relevant callbacks.
33
- */
34
- var responderInst = null;
35
-
36
- /**
37
- * Count of current touches. A textInput should become responder iff the
38
- * selection changes while there is a touch on the screen.
39
- */
40
- var trackedTouchCount = 0;
41
-
42
- /**
43
- * Last reported number of active touches.
44
- */
45
- var previousActiveTouches = 0;
46
-
47
- var changeResponder = function (nextResponderInst, blockHostResponder) {
48
- var oldResponderInst = responderInst;
49
- responderInst = nextResponderInst;
50
- if (ResponderEventPlugin.GlobalResponderHandler !== null) {
51
- ResponderEventPlugin.GlobalResponderHandler.onChange(oldResponderInst, nextResponderInst, blockHostResponder);
52
- }
53
- };
54
-
55
- var eventTypes = {
56
- /**
57
- * On a `touchStart`/`mouseDown`, is it desired that this element become the
58
- * responder?
59
- */
60
- startShouldSetResponder: {
61
- phasedRegistrationNames: {
62
- bubbled: keyOf({ onStartShouldSetResponder: null }),
63
- captured: keyOf({ onStartShouldSetResponderCapture: null })
64
- }
65
- },
66
-
67
- /**
68
- * On a `scroll`, is it desired that this element become the responder? This
69
- * is usually not needed, but should be used to retroactively infer that a
70
- * `touchStart` had occurred during momentum scroll. During a momentum scroll,
71
- * a touch start will be immediately followed by a scroll event if the view is
72
- * currently scrolling.
73
- *
74
- * TODO: This shouldn't bubble.
75
- */
76
- scrollShouldSetResponder: {
77
- phasedRegistrationNames: {
78
- bubbled: keyOf({ onScrollShouldSetResponder: null }),
79
- captured: keyOf({ onScrollShouldSetResponderCapture: null })
80
- }
81
- },
82
-
83
- /**
84
- * On text selection change, should this element become the responder? This
85
- * is needed for text inputs or other views with native selection, so the
86
- * JS view can claim the responder.
87
- *
88
- * TODO: This shouldn't bubble.
89
- */
90
- selectionChangeShouldSetResponder: {
91
- phasedRegistrationNames: {
92
- bubbled: keyOf({ onSelectionChangeShouldSetResponder: null }),
93
- captured: keyOf({ onSelectionChangeShouldSetResponderCapture: null })
94
- }
95
- },
96
-
97
- /**
98
- * On a `touchMove`/`mouseMove`, is it desired that this element become the
99
- * responder?
100
- */
101
- moveShouldSetResponder: {
102
- phasedRegistrationNames: {
103
- bubbled: keyOf({ onMoveShouldSetResponder: null }),
104
- captured: keyOf({ onMoveShouldSetResponderCapture: null })
105
- }
106
- },
107
-
108
- /**
109
- * Direct responder events dispatched directly to responder. Do not bubble.
110
- */
111
- responderStart: { registrationName: keyOf({ onResponderStart: null }) },
112
- responderMove: { registrationName: keyOf({ onResponderMove: null }) },
113
- responderEnd: { registrationName: keyOf({ onResponderEnd: null }) },
114
- responderRelease: { registrationName: keyOf({ onResponderRelease: null }) },
115
- responderTerminationRequest: {
116
- registrationName: keyOf({ onResponderTerminationRequest: null })
117
- },
118
- responderGrant: { registrationName: keyOf({ onResponderGrant: null }) },
119
- responderReject: { registrationName: keyOf({ onResponderReject: null }) },
120
- responderTerminate: { registrationName: keyOf({ onResponderTerminate: null }) }
121
- };
122
-
123
- /**
124
- *
125
- * Responder System:
126
- * ----------------
127
- *
128
- * - A global, solitary "interaction lock" on a view.
129
- * - If a node becomes the responder, it should convey visual feedback
130
- * immediately to indicate so, either by highlighting or moving accordingly.
131
- * - To be the responder means, that touches are exclusively important to that
132
- * responder view, and no other view.
133
- * - While touches are still occurring, the responder lock can be transferred to
134
- * a new view, but only to increasingly "higher" views (meaning ancestors of
135
- * the current responder).
136
- *
137
- * Responder being granted:
138
- * ------------------------
139
- *
140
- * - Touch starts, moves, and scrolls can cause an ID to become the responder.
141
- * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to
142
- * the "appropriate place".
143
- * - If nothing is currently the responder, the "appropriate place" is the
144
- * initiating event's `targetID`.
145
- * - If something *is* already the responder, the "appropriate place" is the
146
- * first common ancestor of the event target and the current `responderInst`.
147
- * - Some negotiation happens: See the timing diagram below.
148
- * - Scrolled views automatically become responder. The reasoning is that a
149
- * platform scroll view that isn't built on top of the responder system has
150
- * began scrolling, and the active responder must now be notified that the
151
- * interaction is no longer locked to it - the system has taken over.
152
- *
153
- * - Responder being released:
154
- * As soon as no more touches that *started* inside of descendants of the
155
- * *current* responderInst, an `onResponderRelease` event is dispatched to the
156
- * current responder, and the responder lock is released.
157
- *
158
- * TODO:
159
- * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that
160
- * determines if the responder lock should remain.
161
- * - If a view shouldn't "remain" the responder, any active touches should by
162
- * default be considered "dead" and do not influence future negotiations or
163
- * bubble paths. It should be as if those touches do not exist.
164
- * -- For multitouch: Usually a translate-z will choose to "remain" responder
165
- * after one out of many touches ended. For translate-y, usually the view
166
- * doesn't wish to "remain" responder after one of many touches end.
167
- * - Consider building this on top of a `stopPropagation` model similar to
168
- * `W3C` events.
169
- * - Ensure that `onResponderTerminate` is called on touch cancels, whether or
170
- * not `onResponderTerminationRequest` returns `true` or `false`.
171
- *
172
- */
173
-
174
- /* Negotiation Performed
175
- +-----------------------+
176
- / \
177
- Process low level events to + Current Responder + wantsResponderID
178
- determine who to perform negot-| (if any exists at all) |
179
- iation/transition | Otherwise just pass through|
180
- -------------------------------+----------------------------+------------------+
181
- Bubble to find first ID | |
182
- to return true:wantsResponderID| |
183
- | |
184
- +-------------+ | |
185
- | onTouchStart| | |
186
- +------+------+ none | |
187
- | return| |
188
- +-----------v-------------+true| +------------------------+ |
189
- |onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+
190
- +-----------+-------------+ | +------------------------+ | |
191
- | | | +--------+-------+
192
- | returned true for| false:REJECT +-------->|onResponderReject
193
- | wantsResponderID | | | +----------------+
194
- | (now attempt | +------------------+-----+ |
195
- | handoff) | | onResponder | |
196
- +------------------->| TerminationRequest| |
197
- | +------------------+-----+ |
198
- | | | +----------------+
199
- | true:GRANT +-------->|onResponderGrant|
200
- | | +--------+-------+
201
- | +------------------------+ | |
202
- | | onResponderTerminate |<-----------+
203
- | +------------------+-----+ |
204
- | | | +----------------+
205
- | +-------->|onResponderStart|
206
- | | +----------------+
207
- Bubble to find first ID | |
208
- to return true:wantsResponderID| |
209
- | |
210
- +-------------+ | |
211
- | onTouchMove | | |
212
- +------+------+ none | |
213
- | return| |
214
- +-----------v-------------+true| +------------------------+ |
215
- |onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+
216
- +-----------+-------------+ | +------------------------+ | |
217
- | | | +--------+-------+
218
- | returned true for| false:REJECT +-------->|onResponderRejec|
219
- | wantsResponderID | | | +----------------+
220
- | (now attempt | +------------------+-----+ |
221
- | handoff) | | onResponder | |
222
- +------------------->| TerminationRequest| |
223
- | +------------------+-----+ |
224
- | | | +----------------+
225
- | true:GRANT +-------->|onResponderGrant|
226
- | | +--------+-------+
227
- | +------------------------+ | |
228
- | | onResponderTerminate |<-----------+
229
- | +------------------+-----+ |
230
- | | | +----------------+
231
- | +-------->|onResponderMove |
232
- | | +----------------+
233
- | |
234
- | |
235
- Some active touch started| |
236
- inside current responder | +------------------------+ |
237
- +------------------------->| onResponderEnd | |
238
- | | +------------------------+ |
239
- +---+---------+ | |
240
- | onTouchEnd | | |
241
- +---+---------+ | |
242
- | | +------------------------+ |
243
- +------------------------->| onResponderEnd | |
244
- No active touches started| +-----------+------------+ |
245
- inside current responder | | |
246
- | v |
247
- | +------------------------+ |
248
- | | onResponderRelease | |
249
- | +------------------------+ |
250
- | |
251
- + + */
252
-
253
- /**
254
- * A note about event ordering in the `EventPluginHub`.
255
- *
256
- * Suppose plugins are injected in the following order:
257
- *
258
- * `[R, S, C]`
259
- *
260
- * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for
261
- * `onClick` etc) and `R` is `ResponderEventPlugin`.
262
- *
263
- * "Deferred-Dispatched Events":
264
- *
265
- * - The current event plugin system will traverse the list of injected plugins,
266
- * in order, and extract events by collecting the plugin's return value of
267
- * `extractEvents()`.
268
- * - These events that are returned from `extractEvents` are "deferred
269
- * dispatched events".
270
- * - When returned from `extractEvents`, deferred-dispatched events contain an
271
- * "accumulation" of deferred dispatches.
272
- * - These deferred dispatches are accumulated/collected before they are
273
- * returned, but processed at a later time by the `EventPluginHub` (hence the
274
- * name deferred).
275
- *
276
- * In the process of returning their deferred-dispatched events, event plugins
277
- * themselves can dispatch events on-demand without returning them from
278
- * `extractEvents`. Plugins might want to do this, so that they can use event
279
- * dispatching as a tool that helps them decide which events should be extracted
280
- * in the first place.
281
- *
282
- * "On-Demand-Dispatched Events":
283
- *
284
- * - On-demand-dispatched events are not returned from `extractEvents`.
285
- * - On-demand-dispatched events are dispatched during the process of returning
286
- * the deferred-dispatched events.
287
- * - They should not have side effects.
288
- * - They should be avoided, and/or eventually be replaced with another
289
- * abstraction that allows event plugins to perform multiple "rounds" of event
290
- * extraction.
291
- *
292
- * Therefore, the sequence of event dispatches becomes:
293
- *
294
- * - `R`s on-demand events (if any) (dispatched by `R` on-demand)
295
- * - `S`s on-demand events (if any) (dispatched by `S` on-demand)
296
- * - `C`s on-demand events (if any) (dispatched by `C` on-demand)
297
- * - `R`s extracted events (if any) (dispatched by `EventPluginHub`)
298
- * - `S`s extracted events (if any) (dispatched by `EventPluginHub`)
299
- * - `C`s extracted events (if any) (dispatched by `EventPluginHub`)
300
- *
301
- * In the case of `ResponderEventPlugin`: If the `startShouldSetResponder`
302
- * on-demand dispatch returns `true` (and some other details are satisfied) the
303
- * `onResponderGrant` deferred dispatched event is returned from
304
- * `extractEvents`. The sequence of dispatch executions in this case
305
- * will appear as follows:
306
- *
307
- * - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand)
308
- * - `touchStartCapture` (`EventPluginHub` dispatches as usual)
309
- * - `touchStart` (`EventPluginHub` dispatches as usual)
310
- * - `responderGrant/Reject` (`EventPluginHub` dispatches as usual)
311
- */
312
-
313
- function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
314
- var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === EventConstants.topLevelTypes.topSelectionChange ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
315
-
316
- // TODO: stop one short of the current responder.
317
- var bubbleShouldSetFrom = !responderInst ? targetInst : EventPluginUtils.getLowestCommonAncestor(responderInst, targetInst);
318
-
319
- // When capturing/bubbling the "shouldSet" event, we want to skip the target
320
- // (deepest ID) if it happens to be the current responder. The reasoning:
321
- // It's strange to get an `onMoveShouldSetResponder` when you're *already*
322
- // the responder.
323
- var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst;
324
- var shouldSetEvent = ResponderSyntheticEvent.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
325
- shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
326
- if (skipOverBubbleShouldSetFrom) {
327
- EventPropagators.accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent);
328
- } else {
329
- EventPropagators.accumulateTwoPhaseDispatches(shouldSetEvent);
330
- }
331
- var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
332
- if (!shouldSetEvent.isPersistent()) {
333
- shouldSetEvent.constructor.release(shouldSetEvent);
334
- }
335
-
336
- if (!wantsResponderInst || wantsResponderInst === responderInst) {
337
- return null;
338
- }
339
- var extracted;
340
- var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
341
- grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
342
-
343
- EventPropagators.accumulateDirectDispatches(grantEvent);
344
- var blockHostResponder = executeDirectDispatch(grantEvent) === true;
345
- if (responderInst) {
346
-
347
- var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
348
- terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
349
- EventPropagators.accumulateDirectDispatches(terminationRequestEvent);
350
- var shouldSwitch = !hasDispatches(terminationRequestEvent) || executeDirectDispatch(terminationRequestEvent);
351
- if (!terminationRequestEvent.isPersistent()) {
352
- terminationRequestEvent.constructor.release(terminationRequestEvent);
353
- }
354
-
355
- if (shouldSwitch) {
356
- var terminateEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget);
357
- terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
358
- EventPropagators.accumulateDirectDispatches(terminateEvent);
359
- extracted = accumulate(extracted, [grantEvent, terminateEvent]);
360
- changeResponder(wantsResponderInst, blockHostResponder);
361
- } else {
362
- var rejectEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderReject, wantsResponderInst, nativeEvent, nativeEventTarget);
363
- rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
364
- EventPropagators.accumulateDirectDispatches(rejectEvent);
365
- extracted = accumulate(extracted, rejectEvent);
366
- }
367
- } else {
368
- extracted = accumulate(extracted, grantEvent);
369
- changeResponder(wantsResponderInst, blockHostResponder);
370
- }
371
- return extracted;
372
- }
373
-
374
- /**
375
- * A transfer is a negotiation between a currently set responder and the next
376
- * element to claim responder status. Any start event could trigger a transfer
377
- * of responderInst. Any move event could trigger a transfer.
378
- *
379
- * @param {string} topLevelType Record from `EventConstants`.
380
- * @return {boolean} True if a transfer of responder could possibly occur.
381
- */
382
- function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
383
- return topLevelInst && (
384
- // responderIgnoreScroll: We are trying to migrate away from specifically
385
- // tracking native scroll events here and responderIgnoreScroll indicates we
386
- // will send topTouchCancel to handle canceling touch events instead
387
- topLevelType === EventConstants.topLevelTypes.topScroll && !nativeEvent.responderIgnoreScroll || trackedTouchCount > 0 && topLevelType === EventConstants.topLevelTypes.topSelectionChange || isStartish(topLevelType) || isMoveish(topLevelType));
388
- }
389
-
390
- /**
391
- * Returns whether or not this touch end event makes it such that there are no
392
- * longer any touches that started inside of the current `responderInst`.
393
- *
394
- * @param {NativeEvent} nativeEvent Native touch end event.
395
- * @return {boolean} Whether or not this touch end event ends the responder.
396
- */
397
- function noResponderTouches(nativeEvent) {
398
- var touches = nativeEvent.touches;
399
- if (!touches || touches.length === 0) {
400
- return true;
401
- }
402
- for (var i = 0; i < touches.length; i++) {
403
- var activeTouch = touches[i];
404
- var target = activeTouch.target;
405
- if (target !== null && target !== undefined && target !== 0) {
406
- // Is the original touch location inside of the current responder?
407
- var targetInst = EventPluginUtils.getInstanceFromNode(target);
408
- if (EventPluginUtils.isAncestor(responderInst, targetInst)) {
409
- return false;
410
- }
411
- }
412
- }
413
- return true;
414
- }
415
-
416
- var ResponderEventPlugin = {
417
-
418
- /* For unit testing only */
419
- _getResponderID: function () {
420
- return responderInst ? responderInst._rootNodeID : null;
421
- },
422
-
423
- eventTypes: eventTypes,
424
-
425
- /**
426
- * We must be resilient to `targetInst` being `null` on `touchMove` or
427
- * `touchEnd`. On certain platforms, this means that a native scroll has
428
- * assumed control and the original touch targets are destroyed.
429
- */
430
- extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
431
- if (isStartish(topLevelType)) {
432
- trackedTouchCount += 1;
433
- } else if (isEndish(topLevelType)) {
434
- if (trackedTouchCount >= 0) {
435
- trackedTouchCount -= 1;
436
- } else {
437
- console.error('Ended a touch event which was not counted in `trackedTouchCount`.');
438
- return null;
439
- }
440
- }
441
-
442
- ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
443
-
444
- var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null;
445
- // Responder may or may not have transferred on a new touch start/move.
446
- // Regardless, whoever is the responder after any potential transfer, we
447
- // direct all touch start/move/ends to them in the form of
448
- // `onResponderMove/Start/End`. These will be called for *every* additional
449
- // finger that move/start/end, dispatched directly to whoever is the
450
- // current responder at that moment, until the responder is "released".
451
- //
452
- // These multiple individual change touch events are are always bookended
453
- // by `onResponderGrant`, and one of
454
- // (`onResponderRelease/onResponderTerminate`).
455
- var isResponderTouchStart = responderInst && isStartish(topLevelType);
456
- var isResponderTouchMove = responderInst && isMoveish(topLevelType);
457
- var isResponderTouchEnd = responderInst && isEndish(topLevelType);
458
- var incrementalTouch = isResponderTouchStart ? eventTypes.responderStart : isResponderTouchMove ? eventTypes.responderMove : isResponderTouchEnd ? eventTypes.responderEnd : null;
459
-
460
- if (incrementalTouch) {
461
- var gesture = ResponderSyntheticEvent.getPooled(incrementalTouch, responderInst, nativeEvent, nativeEventTarget);
462
- gesture.touchHistory = ResponderTouchHistoryStore.touchHistory;
463
- EventPropagators.accumulateDirectDispatches(gesture);
464
- extracted = accumulate(extracted, gesture);
465
- }
466
-
467
- var isResponderTerminate = responderInst && topLevelType === EventConstants.topLevelTypes.topTouchCancel;
468
- var isResponderRelease = responderInst && !isResponderTerminate && isEndish(topLevelType) && noResponderTouches(nativeEvent);
469
- var finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
470
- if (finalTouch) {
471
- var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
472
- finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
473
- EventPropagators.accumulateDirectDispatches(finalEvent);
474
- extracted = accumulate(extracted, finalEvent);
475
- changeResponder(null);
476
- }
477
-
478
- var numberActiveTouches = ResponderTouchHistoryStore.touchHistory.numberActiveTouches;
479
- if (ResponderEventPlugin.GlobalInteractionHandler && numberActiveTouches !== previousActiveTouches) {
480
- ResponderEventPlugin.GlobalInteractionHandler.onChange(numberActiveTouches);
481
- }
482
- previousActiveTouches = numberActiveTouches;
483
-
484
- return extracted;
485
- },
486
-
487
- GlobalResponderHandler: null,
488
- GlobalInteractionHandler: null,
489
-
490
- injection: {
491
- /**
492
- * @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler
493
- * Object that handles any change in responder. Use this to inject
494
- * integration with an existing touch handling system etc.
495
- */
496
- injectGlobalResponderHandler: function (GlobalResponderHandler) {
497
- ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler;
498
- },
499
-
500
- /**
501
- * @param {{onChange: (numberActiveTouches) => void} GlobalInteractionHandler
502
- * Object that handles any change in the number of active touches.
503
- */
504
- injectGlobalInteractionHandler: function (GlobalInteractionHandler) {
505
- ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler;
506
- }
507
- }
508
- };
509
-
510
- module.exports = ResponderEventPlugin;