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,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;