react 0.14.0-beta1 → 0.14.0
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.
- package/addons.js +8 -3
- package/dist/react-with-addons.js +5048 -4095
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4555 -3729
- package/dist/react.min.js +6 -5
- package/lib/AutoFocusUtils.js +3 -3
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +18 -3
- package/lib/CSSPropertyOperations.js +27 -14
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +15 -14
- package/lib/DOMChildrenOperations.js +22 -7
- package/lib/DOMProperty.js +8 -8
- package/lib/DOMPropertyOperations.js +23 -10
- package/lib/Danger.js +21 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +18 -10
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +29 -21
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +34 -38
- package/lib/EventPropagators.js +8 -8
- package/lib/FallbackCompositionState.js +9 -3
- package/lib/HTMLDOMPropertyConfig.js +24 -4
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +8 -8
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +3 -5
- package/lib/React.js +18 -7
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +36 -7
- package/lib/ReactCSSTransitionGroup.js +35 -9
- package/lib/ReactCSSTransitionGroupChild.js +48 -30
- package/lib/ReactChildReconciler.js +24 -19
- package/lib/ReactChildren.js +72 -32
- package/lib/ReactClass.js +46 -46
- package/lib/ReactComponent.js +18 -16
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +95 -44
- package/lib/ReactDOM.js +74 -159
- package/lib/ReactDOMComponent.js +235 -93
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
- package/lib/ReactDOMIDOperations.js +8 -81
- package/lib/ReactDOMInput.js +18 -9
- package/lib/ReactDOMOption.js +7 -7
- package/lib/ReactDOMSelect.js +9 -9
- package/lib/ReactDOMSelection.js +19 -3
- package/lib/ReactDOMServer.js +5 -3
- package/lib/ReactDOMTextComponent.js +33 -20
- package/lib/ReactDOMTextarea.js +14 -12
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +23 -25
- package/lib/ReactDefaultPerf.js +17 -11
- package/lib/ReactDefaultPerfAnalysis.js +13 -12
- package/lib/ReactElement.js +85 -39
- package/lib/ReactElementValidator.js +47 -90
- package/lib/ReactEmptyComponent.js +26 -62
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +53 -9
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +33 -21
- package/lib/ReactFragment.js +27 -118
- package/lib/ReactInjection.js +10 -12
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -11
- package/lib/ReactIsomorphic.js +15 -11
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +186 -85
- package/lib/ReactMultiChild.js +119 -25
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -3
- package/lib/ReactNoopUpdateQueue.js +3 -3
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +38 -9
- package/lib/ReactReconcileTransaction.js +10 -8
- package/lib/ReactReconciler.js +5 -6
- package/lib/ReactRef.js +14 -2
- package/lib/ReactServerBatchingStrategy.js +5 -5
- package/lib/ReactServerRendering.js +12 -12
- package/lib/ReactServerRenderingTransaction.js +6 -5
- package/lib/ReactTestUtils.js +47 -39
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +19 -19
- package/lib/ReactUpdates.js +15 -15
- package/lib/{performance.js → ReactVersion.js} +3 -12
- package/lib/ReactWithAddons.js +24 -15
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +19 -9
- package/lib/SimpleEventPlugin.js +198 -43
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +18 -4
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +3 -3
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +7 -7
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +11 -6
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +7 -6
- package/lib/findDOMNode.js +9 -9
- package/lib/flattenChildren.js +4 -4
- package/lib/getEventKey.js +1 -1
- package/lib/{isTextNode.js → getTestDocument.js} +7 -11
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +15 -17
- package/lib/isEventSupported.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +216 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +1 -1
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +34 -0
- package/lib/traverseAllChildren.js +25 -18
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +6 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +1 -51
- package/dist/JSXTransformer.js +0 -17588
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/ReactDOMClient.js +0 -90
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -93
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/joinClasses.js +0 -39
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/memoizeStringOnly.js +0 -31
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -57
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var React = require(
|
|
15
|
-
var ReactTransitionChildMapping = require(
|
|
14
|
+
var React = require('./React');
|
|
15
|
+
var ReactTransitionChildMapping = require('./ReactTransitionChildMapping');
|
|
16
16
|
|
|
17
|
-
var assign = require(
|
|
18
|
-
var
|
|
19
|
-
var emptyFunction = require("./emptyFunction");
|
|
17
|
+
var assign = require('./Object.assign');
|
|
18
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
20
19
|
|
|
21
20
|
var ReactTransitionGroup = React.createClass({
|
|
22
21
|
displayName: 'ReactTransitionGroup',
|
|
@@ -196,7 +195,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
196
195
|
// already been removed. In case you need this behavior you can provide
|
|
197
196
|
// a childFactory function to wrap every child, even the ones that are
|
|
198
197
|
// leaving.
|
|
199
|
-
childrenToRender.push(
|
|
198
|
+
childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
return React.createElement(this.props.component, this.props, childrenToRender);
|
package/lib/ReactUpdateQueue.js
CHANGED
|
@@ -11,35 +11,35 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactCurrentOwner = require(
|
|
15
|
-
var ReactElement = require(
|
|
16
|
-
var ReactInstanceMap = require(
|
|
17
|
-
var ReactUpdates = require(
|
|
14
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
15
|
+
var ReactElement = require('./ReactElement');
|
|
16
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
17
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
18
18
|
|
|
19
|
-
var assign = require(
|
|
20
|
-
var invariant = require(
|
|
21
|
-
var warning = require(
|
|
19
|
+
var assign = require('./Object.assign');
|
|
20
|
+
var invariant = require('fbjs/lib/invariant');
|
|
21
|
+
var warning = require('fbjs/lib/warning');
|
|
22
22
|
|
|
23
23
|
function enqueueUpdate(internalInstance) {
|
|
24
24
|
ReactUpdates.enqueueUpdate(internalInstance);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
|
|
28
|
-
if ('production' !== process.env.NODE_ENV) {
|
|
29
|
-
'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
var internalInstance = ReactInstanceMap.get(publicInstance);
|
|
33
29
|
if (!internalInstance) {
|
|
34
|
-
if (
|
|
30
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
31
|
// Only warn when we have a callerName. Otherwise we should be silent.
|
|
36
32
|
// We're probably calling from enqueueCallback. We don't want to warn
|
|
37
33
|
// there because we already warned for the corresponding lifecycle method.
|
|
38
|
-
|
|
34
|
+
process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : undefined;
|
|
39
35
|
}
|
|
40
36
|
return null;
|
|
41
37
|
}
|
|
42
38
|
|
|
39
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
40
|
+
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
43
|
return internalInstance;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -57,10 +57,10 @@ var ReactUpdateQueue = {
|
|
|
57
57
|
* @final
|
|
58
58
|
*/
|
|
59
59
|
isMounted: function (publicInstance) {
|
|
60
|
-
if (
|
|
60
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
61
61
|
var owner = ReactCurrentOwner.current;
|
|
62
62
|
if (owner !== null) {
|
|
63
|
-
|
|
63
|
+
process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
|
|
64
64
|
owner._warnedAboutRefsInRender = true;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -84,7 +84,7 @@ var ReactUpdateQueue = {
|
|
|
84
84
|
* @internal
|
|
85
85
|
*/
|
|
86
86
|
enqueueCallback: function (publicInstance, callback) {
|
|
87
|
-
!(typeof callback === 'function') ?
|
|
87
|
+
!(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
|
|
88
88
|
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
|
|
89
89
|
|
|
90
90
|
// Previously we would throw an error if we didn't have an internal
|
|
@@ -109,7 +109,7 @@ var ReactUpdateQueue = {
|
|
|
109
109
|
},
|
|
110
110
|
|
|
111
111
|
enqueueCallbackInternal: function (internalInstance, callback) {
|
|
112
|
-
!(typeof callback === 'function') ?
|
|
112
|
+
!(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
|
|
113
113
|
if (internalInstance._pendingCallbacks) {
|
|
114
114
|
internalInstance._pendingCallbacks.push(callback);
|
|
115
115
|
} else {
|
|
@@ -207,7 +207,7 @@ var ReactUpdateQueue = {
|
|
|
207
207
|
|
|
208
208
|
enqueueSetPropsInternal: function (internalInstance, partialProps) {
|
|
209
209
|
var topLevelWrapper = internalInstance._topLevelWrapper;
|
|
210
|
-
!topLevelWrapper ?
|
|
210
|
+
!topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setProps(...): You called `setProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
|
|
211
211
|
|
|
212
212
|
// Merge with the pending element if it exists, otherwise with existing
|
|
213
213
|
// element props.
|
|
@@ -236,7 +236,7 @@ var ReactUpdateQueue = {
|
|
|
236
236
|
|
|
237
237
|
enqueueReplacePropsInternal: function (internalInstance, props) {
|
|
238
238
|
var topLevelWrapper = internalInstance._topLevelWrapper;
|
|
239
|
-
!topLevelWrapper ?
|
|
239
|
+
!topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'replaceProps(...): You called `replaceProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
|
|
240
240
|
|
|
241
241
|
// Merge with the pending element if it exists, otherwise with existing
|
|
242
242
|
// element props.
|
package/lib/ReactUpdates.js
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var CallbackQueue = require(
|
|
15
|
-
var PooledClass = require(
|
|
16
|
-
var ReactPerf = require(
|
|
17
|
-
var ReactReconciler = require(
|
|
18
|
-
var Transaction = require(
|
|
14
|
+
var CallbackQueue = require('./CallbackQueue');
|
|
15
|
+
var PooledClass = require('./PooledClass');
|
|
16
|
+
var ReactPerf = require('./ReactPerf');
|
|
17
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
18
|
+
var Transaction = require('./Transaction');
|
|
19
19
|
|
|
20
|
-
var assign = require(
|
|
21
|
-
var invariant = require(
|
|
20
|
+
var assign = require('./Object.assign');
|
|
21
|
+
var invariant = require('fbjs/lib/invariant');
|
|
22
22
|
|
|
23
23
|
var dirtyComponents = [];
|
|
24
24
|
var asapCallbackQueue = CallbackQueue.getPooled();
|
|
@@ -27,7 +27,7 @@ var asapEnqueued = false;
|
|
|
27
27
|
var batchingStrategy = null;
|
|
28
28
|
|
|
29
29
|
function ensureInjected() {
|
|
30
|
-
!(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ?
|
|
30
|
+
!(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must inject a reconcile transaction class and batching ' + 'strategy') : invariant(false) : undefined;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
var NESTED_UPDATES = {
|
|
@@ -64,7 +64,7 @@ function ReactUpdatesFlushTransaction() {
|
|
|
64
64
|
this.reinitializeTransaction();
|
|
65
65
|
this.dirtyComponentsLength = null;
|
|
66
66
|
this.callbackQueue = CallbackQueue.getPooled();
|
|
67
|
-
this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled();
|
|
67
|
+
this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled( /* forceHTML */false);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
|
|
@@ -107,7 +107,7 @@ function mountOrderComparator(c1, c2) {
|
|
|
107
107
|
|
|
108
108
|
function runBatchedUpdates(transaction) {
|
|
109
109
|
var len = transaction.dirtyComponentsLength;
|
|
110
|
-
!(len === dirtyComponents.length) ?
|
|
110
|
+
!(len === dirtyComponents.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected flush transaction\'s stored dirty-components length (%s) to ' + 'match dirty-components array length (%s).', len, dirtyComponents.length) : invariant(false) : undefined;
|
|
111
111
|
|
|
112
112
|
// Since reconciling a component higher in the owner hierarchy usually (not
|
|
113
113
|
// always -- see shouldComponentUpdate()) will reconcile children, reconcile
|
|
@@ -185,21 +185,21 @@ function enqueueUpdate(component) {
|
|
|
185
185
|
* if no updates are currently being performed.
|
|
186
186
|
*/
|
|
187
187
|
function asap(callback, context) {
|
|
188
|
-
!batchingStrategy.isBatchingUpdates ?
|
|
188
|
+
!batchingStrategy.isBatchingUpdates ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' + 'updates are not being batched.') : invariant(false) : undefined;
|
|
189
189
|
asapCallbackQueue.enqueue(callback, context);
|
|
190
190
|
asapEnqueued = true;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
var ReactUpdatesInjection = {
|
|
194
194
|
injectReconcileTransaction: function (ReconcileTransaction) {
|
|
195
|
-
!ReconcileTransaction ?
|
|
195
|
+
!ReconcileTransaction ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a reconcile transaction class') : invariant(false) : undefined;
|
|
196
196
|
ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
|
|
197
197
|
},
|
|
198
198
|
|
|
199
199
|
injectBatchingStrategy: function (_batchingStrategy) {
|
|
200
|
-
!_batchingStrategy ?
|
|
201
|
-
!(typeof _batchingStrategy.batchedUpdates === 'function') ?
|
|
202
|
-
!(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ?
|
|
200
|
+
!_batchingStrategy ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batching strategy') : invariant(false) : undefined;
|
|
201
|
+
!(typeof _batchingStrategy.batchedUpdates === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batchedUpdates() function') : invariant(false) : undefined;
|
|
202
|
+
!(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide an isBatchingUpdates boolean attribute') : invariant(false) : undefined;
|
|
203
203
|
batchingStrategy = _batchingStrategy;
|
|
204
204
|
}
|
|
205
205
|
};
|
|
@@ -6,18 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @providesModule
|
|
10
|
-
* @typechecks
|
|
9
|
+
* @providesModule ReactVersion
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
'use strict';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var performance;
|
|
18
|
-
|
|
19
|
-
if (ExecutionEnvironment.canUseDOM) {
|
|
20
|
-
performance = window.performance || window.msPerformance || window.webkitPerformance;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = performance || {};
|
|
14
|
+
module.exports = '0.14.0';
|
package/lib/ReactWithAddons.js
CHANGED
|
@@ -18,17 +18,20 @@
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
var LinkedStateMixin = require(
|
|
22
|
-
var React = require(
|
|
23
|
-
var ReactComponentWithPureRenderMixin = require(
|
|
24
|
-
var ReactCSSTransitionGroup = require(
|
|
25
|
-
var ReactFragment = require(
|
|
26
|
-
var ReactTransitionGroup = require(
|
|
27
|
-
var ReactUpdates = require(
|
|
28
|
-
|
|
29
|
-
var cloneWithProps = require(
|
|
30
|
-
var shallowCompare = require(
|
|
31
|
-
var update = require(
|
|
21
|
+
var LinkedStateMixin = require('./LinkedStateMixin');
|
|
22
|
+
var React = require('./React');
|
|
23
|
+
var ReactComponentWithPureRenderMixin = require('./ReactComponentWithPureRenderMixin');
|
|
24
|
+
var ReactCSSTransitionGroup = require('./ReactCSSTransitionGroup');
|
|
25
|
+
var ReactFragment = require('./ReactFragment');
|
|
26
|
+
var ReactTransitionGroup = require('./ReactTransitionGroup');
|
|
27
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
28
|
+
|
|
29
|
+
var cloneWithProps = require('./cloneWithProps');
|
|
30
|
+
var shallowCompare = require('./shallowCompare');
|
|
31
|
+
var update = require('./update');
|
|
32
|
+
var warning = require('fbjs/lib/warning');
|
|
33
|
+
|
|
34
|
+
var warnedAboutBatchedUpdates = false;
|
|
32
35
|
|
|
33
36
|
React.addons = {
|
|
34
37
|
CSSTransitionGroup: ReactCSSTransitionGroup,
|
|
@@ -36,16 +39,22 @@ React.addons = {
|
|
|
36
39
|
PureRenderMixin: ReactComponentWithPureRenderMixin,
|
|
37
40
|
TransitionGroup: ReactTransitionGroup,
|
|
38
41
|
|
|
39
|
-
batchedUpdates:
|
|
42
|
+
batchedUpdates: function () {
|
|
43
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
44
|
+
process.env.NODE_ENV !== 'production' ? warning(warnedAboutBatchedUpdates, 'React.addons.batchedUpdates is deprecated. Use ' + 'ReactDOM.unstable_batchedUpdates instead.') : undefined;
|
|
45
|
+
warnedAboutBatchedUpdates = true;
|
|
46
|
+
}
|
|
47
|
+
return ReactUpdates.batchedUpdates.apply(this, arguments);
|
|
48
|
+
},
|
|
40
49
|
cloneWithProps: cloneWithProps,
|
|
41
50
|
createFragment: ReactFragment.create,
|
|
42
51
|
shallowCompare: shallowCompare,
|
|
43
52
|
update: update
|
|
44
53
|
};
|
|
45
54
|
|
|
46
|
-
if (
|
|
47
|
-
React.addons.Perf = require(
|
|
48
|
-
React.addons.TestUtils = require(
|
|
55
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
56
|
+
React.addons.Perf = require('./ReactDefaultPerf');
|
|
57
|
+
React.addons.TestUtils = require('./ReactTestUtils');
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
module.exports = React;
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2015, 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 ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
18
|
+
var ResponderSyntheticEvent = require('./ResponderSyntheticEvent');
|
|
19
|
+
var ResponderTouchHistoryStore = require('./ResponderTouchHistoryStore');
|
|
20
|
+
|
|
21
|
+
var accumulate = require('./accumulate');
|
|
22
|
+
var invariant = require('fbjs/lib/invariant');
|
|
23
|
+
var keyOf = require('fbjs/lib/keyOf');
|
|
24
|
+
|
|
25
|
+
var isStartish = EventPluginUtils.isStartish;
|
|
26
|
+
var isMoveish = EventPluginUtils.isMoveish;
|
|
27
|
+
var isEndish = EventPluginUtils.isEndish;
|
|
28
|
+
var executeDirectDispatch = EventPluginUtils.executeDirectDispatch;
|
|
29
|
+
var hasDispatches = EventPluginUtils.hasDispatches;
|
|
30
|
+
var executeDispatchesInOrderStopAtTrue = EventPluginUtils.executeDispatchesInOrderStopAtTrue;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ID of element that should respond to touch/move types of interactions, as
|
|
34
|
+
* indicated explicitly by relevant callbacks.
|
|
35
|
+
*/
|
|
36
|
+
var responderID = null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Count of current touches. A textInput should become responder iff the
|
|
40
|
+
* the selection changes while there is a touch on the screen.
|
|
41
|
+
*/
|
|
42
|
+
var trackedTouchCount = 0;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Last reported number of active touches.
|
|
46
|
+
*/
|
|
47
|
+
var previousActiveTouches = 0;
|
|
48
|
+
|
|
49
|
+
var changeResponder = function (nextResponderID) {
|
|
50
|
+
var oldResponderID = responderID;
|
|
51
|
+
responderID = nextResponderID;
|
|
52
|
+
if (ResponderEventPlugin.GlobalResponderHandler !== null) {
|
|
53
|
+
ResponderEventPlugin.GlobalResponderHandler.onChange(oldResponderID, nextResponderID);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var eventTypes = {
|
|
58
|
+
/**
|
|
59
|
+
* On a `touchStart`/`mouseDown`, is it desired that this element become the
|
|
60
|
+
* responder?
|
|
61
|
+
*/
|
|
62
|
+
startShouldSetResponder: {
|
|
63
|
+
phasedRegistrationNames: {
|
|
64
|
+
bubbled: keyOf({ onStartShouldSetResponder: null }),
|
|
65
|
+
captured: keyOf({ onStartShouldSetResponderCapture: null })
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* On a `scroll`, is it desired that this element become the responder? This
|
|
71
|
+
* is usually not needed, but should be used to retroactively infer that a
|
|
72
|
+
* `touchStart` had occurred during momentum scroll. During a momentum scroll,
|
|
73
|
+
* a touch start will be immediately followed by a scroll event if the view is
|
|
74
|
+
* currently scrolling.
|
|
75
|
+
*
|
|
76
|
+
* TODO: This shouldn't bubble.
|
|
77
|
+
*/
|
|
78
|
+
scrollShouldSetResponder: {
|
|
79
|
+
phasedRegistrationNames: {
|
|
80
|
+
bubbled: keyOf({ onScrollShouldSetResponder: null }),
|
|
81
|
+
captured: keyOf({ onScrollShouldSetResponderCapture: null })
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* On text selection change, should this element become the responder? This
|
|
87
|
+
* is needed for text inputs or other views with native selection, so the
|
|
88
|
+
* JS view can claim the responder.
|
|
89
|
+
*
|
|
90
|
+
* TODO: This shouldn't bubble.
|
|
91
|
+
*/
|
|
92
|
+
selectionChangeShouldSetResponder: {
|
|
93
|
+
phasedRegistrationNames: {
|
|
94
|
+
bubbled: keyOf({ onSelectionChangeShouldSetResponder: null }),
|
|
95
|
+
captured: keyOf({ onSelectionChangeShouldSetResponderCapture: null })
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* On a `touchMove`/`mouseMove`, is it desired that this element become the
|
|
101
|
+
* responder?
|
|
102
|
+
*/
|
|
103
|
+
moveShouldSetResponder: {
|
|
104
|
+
phasedRegistrationNames: {
|
|
105
|
+
bubbled: keyOf({ onMoveShouldSetResponder: null }),
|
|
106
|
+
captured: keyOf({ onMoveShouldSetResponderCapture: null })
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Direct responder events dispatched directly to responder. Do not bubble.
|
|
112
|
+
*/
|
|
113
|
+
responderStart: { registrationName: keyOf({ onResponderStart: null }) },
|
|
114
|
+
responderMove: { registrationName: keyOf({ onResponderMove: null }) },
|
|
115
|
+
responderEnd: { registrationName: keyOf({ onResponderEnd: null }) },
|
|
116
|
+
responderRelease: { registrationName: keyOf({ onResponderRelease: null }) },
|
|
117
|
+
responderTerminationRequest: {
|
|
118
|
+
registrationName: keyOf({ onResponderTerminationRequest: null })
|
|
119
|
+
},
|
|
120
|
+
responderGrant: { registrationName: keyOf({ onResponderGrant: null }) },
|
|
121
|
+
responderReject: { registrationName: keyOf({ onResponderReject: null }) },
|
|
122
|
+
responderTerminate: { registrationName: keyOf({ onResponderTerminate: null }) }
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
*
|
|
127
|
+
* Responder System:
|
|
128
|
+
* ----------------
|
|
129
|
+
*
|
|
130
|
+
* - A global, solitary "interaction lock" on a view.
|
|
131
|
+
* - If a node becomes the responder, it should convey visual feedback
|
|
132
|
+
* immediately to indicate so, either by highlighting or moving accordingly.
|
|
133
|
+
* - To be the responder means, that touches are exclusively important to that
|
|
134
|
+
* responder view, and no other view.
|
|
135
|
+
* - While touches are still occuring, the responder lock can be transfered to
|
|
136
|
+
* a new view, but only to increasingly "higher" views (meaning ancestors of
|
|
137
|
+
* the current responder).
|
|
138
|
+
*
|
|
139
|
+
* Responder being granted:
|
|
140
|
+
* ------------------------
|
|
141
|
+
*
|
|
142
|
+
* - Touch starts, moves, and scrolls can cause an ID to become the responder.
|
|
143
|
+
* - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to
|
|
144
|
+
* the "appropriate place".
|
|
145
|
+
* - If nothing is currently the responder, the "appropriate place" is the
|
|
146
|
+
* initiating event's `targetID`.
|
|
147
|
+
* - If something *is* already the responder, the "appropriate place" is the
|
|
148
|
+
* first common ancestor of the event target and the current `responderID`.
|
|
149
|
+
* - Some negotiation happens: See the timing diagram below.
|
|
150
|
+
* - Scrolled views automatically become responder. The reasoning is that a
|
|
151
|
+
* platform scroll view that isn't built on top of the responder system has
|
|
152
|
+
* began scrolling, and the active responder must now be notified that the
|
|
153
|
+
* interaction is no longer locked to it - the system has taken over.
|
|
154
|
+
*
|
|
155
|
+
* - Responder being released:
|
|
156
|
+
* As soon as no more touches that *started* inside of descendents of the
|
|
157
|
+
* *current* responderID, an `onResponderRelease` event is dispatched to the
|
|
158
|
+
* current responder, and the responder lock is released.
|
|
159
|
+
*
|
|
160
|
+
* TODO:
|
|
161
|
+
* - on "end", a callback hook for `onResponderEndShouldRemainResponder` that
|
|
162
|
+
* determines if the responder lock should remain.
|
|
163
|
+
* - If a view shouldn't "remain" the responder, any active touches should by
|
|
164
|
+
* default be considered "dead" and do not influence future negotiations or
|
|
165
|
+
* bubble paths. It should be as if those touches do not exist.
|
|
166
|
+
* -- For multitouch: Usually a translate-z will choose to "remain" responder
|
|
167
|
+
* after one out of many touches ended. For translate-y, usually the view
|
|
168
|
+
* doesn't wish to "remain" responder after one of many touches end.
|
|
169
|
+
* - Consider building this on top of a `stopPropagation` model similar to
|
|
170
|
+
* `W3C` events.
|
|
171
|
+
* - Ensure that `onResponderTerminate` is called on touch cancels, whether or
|
|
172
|
+
* not `onResponderTerminationRequest` returns `true` or `false`.
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
/* Negotiation Performed
|
|
177
|
+
+-----------------------+
|
|
178
|
+
/ \
|
|
179
|
+
Process low level events to + Current Responder + wantsResponderID
|
|
180
|
+
determine who to perform negot-| (if any exists at all) |
|
|
181
|
+
iation/transition | Otherwise just pass through|
|
|
182
|
+
-------------------------------+----------------------------+------------------+
|
|
183
|
+
Bubble to find first ID | |
|
|
184
|
+
to return true:wantsResponderID| |
|
|
185
|
+
| |
|
|
186
|
+
+-------------+ | |
|
|
187
|
+
| onTouchStart| | |
|
|
188
|
+
+------+------+ none | |
|
|
189
|
+
| return| |
|
|
190
|
+
+-----------v-------------+true| +------------------------+ |
|
|
191
|
+
|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+
|
|
192
|
+
+-----------+-------------+ | +------------------------+ | |
|
|
193
|
+
| | | +--------+-------+
|
|
194
|
+
| returned true for| false:REJECT +-------->|onResponderReject
|
|
195
|
+
| wantsResponderID | | | +----------------+
|
|
196
|
+
| (now attempt | +------------------+-----+ |
|
|
197
|
+
| handoff) | | onResponder | |
|
|
198
|
+
+------------------->| TerminationRequest| |
|
|
199
|
+
| +------------------+-----+ |
|
|
200
|
+
| | | +----------------+
|
|
201
|
+
| true:GRANT +-------->|onResponderGrant|
|
|
202
|
+
| | +--------+-------+
|
|
203
|
+
| +------------------------+ | |
|
|
204
|
+
| | onResponderTerminate |<-----------+
|
|
205
|
+
| +------------------+-----+ |
|
|
206
|
+
| | | +----------------+
|
|
207
|
+
| +-------->|onResponderStart|
|
|
208
|
+
| | +----------------+
|
|
209
|
+
Bubble to find first ID | |
|
|
210
|
+
to return true:wantsResponderID| |
|
|
211
|
+
| |
|
|
212
|
+
+-------------+ | |
|
|
213
|
+
| onTouchMove | | |
|
|
214
|
+
+------+------+ none | |
|
|
215
|
+
| return| |
|
|
216
|
+
+-----------v-------------+true| +------------------------+ |
|
|
217
|
+
|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+
|
|
218
|
+
+-----------+-------------+ | +------------------------+ | |
|
|
219
|
+
| | | +--------+-------+
|
|
220
|
+
| returned true for| false:REJECT +-------->|onResponderRejec|
|
|
221
|
+
| wantsResponderID | | | +----------------+
|
|
222
|
+
| (now attempt | +------------------+-----+ |
|
|
223
|
+
| handoff) | | onResponder | |
|
|
224
|
+
+------------------->| TerminationRequest| |
|
|
225
|
+
| +------------------+-----+ |
|
|
226
|
+
| | | +----------------+
|
|
227
|
+
| true:GRANT +-------->|onResponderGrant|
|
|
228
|
+
| | +--------+-------+
|
|
229
|
+
| +------------------------+ | |
|
|
230
|
+
| | onResponderTerminate |<-----------+
|
|
231
|
+
| +------------------+-----+ |
|
|
232
|
+
| | | +----------------+
|
|
233
|
+
| +-------->|onResponderMove |
|
|
234
|
+
| | +----------------+
|
|
235
|
+
| |
|
|
236
|
+
| |
|
|
237
|
+
Some active touch started| |
|
|
238
|
+
inside current responder | +------------------------+ |
|
|
239
|
+
+------------------------->| onResponderEnd | |
|
|
240
|
+
| | +------------------------+ |
|
|
241
|
+
+---+---------+ | |
|
|
242
|
+
| onTouchEnd | | |
|
|
243
|
+
+---+---------+ | |
|
|
244
|
+
| | +------------------------+ |
|
|
245
|
+
+------------------------->| onResponderEnd | |
|
|
246
|
+
No active touches started| +-----------+------------+ |
|
|
247
|
+
inside current responder | | |
|
|
248
|
+
| v |
|
|
249
|
+
| +------------------------+ |
|
|
250
|
+
| | onResponderRelease | |
|
|
251
|
+
| +------------------------+ |
|
|
252
|
+
| |
|
|
253
|
+
+ + */
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* A note about event ordering in the `EventPluginHub`.
|
|
257
|
+
*
|
|
258
|
+
* Suppose plugins are injected in the following order:
|
|
259
|
+
*
|
|
260
|
+
* `[R, S, C]`
|
|
261
|
+
*
|
|
262
|
+
* To help illustrate the example, assume `S` is `SimpleEventPlugin` (for
|
|
263
|
+
* `onClick` etc) and `R` is `ResponderEventPlugin`.
|
|
264
|
+
*
|
|
265
|
+
* "Deferred-Dispatched Events":
|
|
266
|
+
*
|
|
267
|
+
* - The current event plugin system will traverse the list of injected plugins,
|
|
268
|
+
* in order, and extract events by collecting the plugin's return value of
|
|
269
|
+
* `extractEvents()`.
|
|
270
|
+
* - These events that are returned from `extractEvents` are "deferred
|
|
271
|
+
* dispatched events".
|
|
272
|
+
* - When returned from `extractEvents`, deferred-dispatched events contain an
|
|
273
|
+
* "accumulation" of deferred dispatches.
|
|
274
|
+
* - These deferred dispatches are accumulated/collected before they are
|
|
275
|
+
* returned, but processed at a later time by the `EventPluginHub` (hence the
|
|
276
|
+
* name deferred).
|
|
277
|
+
*
|
|
278
|
+
* In the process of returning their deferred-dispatched events, event plugins
|
|
279
|
+
* themselves can dispatch events on-demand without returning them from
|
|
280
|
+
* `extractEvents`. Plugins might want to do this, so that they can use event
|
|
281
|
+
* dispatching as a tool that helps them decide which events should be extracted
|
|
282
|
+
* in the first place.
|
|
283
|
+
*
|
|
284
|
+
* "On-Demand-Dispatched Events":
|
|
285
|
+
*
|
|
286
|
+
* - On-demand-dispatched events are not returned from `extractEvents`.
|
|
287
|
+
* - On-demand-dispatched events are dispatched during the process of returning
|
|
288
|
+
* the deferred-dispatched events.
|
|
289
|
+
* - They should not have side effects.
|
|
290
|
+
* - They should be avoided, and/or eventually be replaced with another
|
|
291
|
+
* abstraction that allows event plugins to perform multiple "rounds" of event
|
|
292
|
+
* extraction.
|
|
293
|
+
*
|
|
294
|
+
* Therefore, the sequence of event dispatches becomes:
|
|
295
|
+
*
|
|
296
|
+
* - `R`s on-demand events (if any) (dispatched by `R` on-demand)
|
|
297
|
+
* - `S`s on-demand events (if any) (dispatched by `S` on-demand)
|
|
298
|
+
* - `C`s on-demand events (if any) (dispatched by `C` on-demand)
|
|
299
|
+
* - `R`s extracted events (if any) (dispatched by `EventPluginHub`)
|
|
300
|
+
* - `S`s extracted events (if any) (dispatched by `EventPluginHub`)
|
|
301
|
+
* - `C`s extracted events (if any) (dispatched by `EventPluginHub`)
|
|
302
|
+
*
|
|
303
|
+
* In the case of `ResponderEventPlugin`: If the `startShouldSetResponder`
|
|
304
|
+
* on-demand dispatch returns `true` (and some other details are satisfied) the
|
|
305
|
+
* `onResponderGrant` deferred dispatched event is returned from
|
|
306
|
+
* `extractEvents`. The sequence of dispatch executions in this case
|
|
307
|
+
* will appear as follows:
|
|
308
|
+
*
|
|
309
|
+
* - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand)
|
|
310
|
+
* - `touchStartCapture` (`EventPluginHub` dispatches as usual)
|
|
311
|
+
* - `touchStart` (`EventPluginHub` dispatches as usual)
|
|
312
|
+
* - `responderGrant/Reject` (`EventPluginHub` dispatches as usual)
|
|
313
|
+
*
|
|
314
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
315
|
+
* @param {string} topLevelTargetID ID of deepest React rendered element.
|
|
316
|
+
* @param {object} nativeEvent Native browser event.
|
|
317
|
+
* @return {*} An accumulation of synthetic events.
|
|
318
|
+
*/
|
|
319
|
+
function setResponderAndExtractTransfer(topLevelType, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
|
320
|
+
var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === EventConstants.topLevelTypes.topSelectionChange ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
|
|
321
|
+
|
|
322
|
+
// TODO: stop one short of the the current responder.
|
|
323
|
+
var bubbleShouldSetFrom = !responderID ? topLevelTargetID : ReactInstanceHandles.getFirstCommonAncestorID(responderID, topLevelTargetID);
|
|
324
|
+
|
|
325
|
+
// When capturing/bubbling the "shouldSet" event, we want to skip the target
|
|
326
|
+
// (deepest ID) if it happens to be the current responder. The reasoning:
|
|
327
|
+
// It's strange to get an `onMoveShouldSetResponder` when you're *already*
|
|
328
|
+
// the responder.
|
|
329
|
+
var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderID;
|
|
330
|
+
var shouldSetEvent = ResponderSyntheticEvent.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
|
|
331
|
+
shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
332
|
+
if (skipOverBubbleShouldSetFrom) {
|
|
333
|
+
EventPropagators.accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent);
|
|
334
|
+
} else {
|
|
335
|
+
EventPropagators.accumulateTwoPhaseDispatches(shouldSetEvent);
|
|
336
|
+
}
|
|
337
|
+
var wantsResponderID = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
|
|
338
|
+
if (!shouldSetEvent.isPersistent()) {
|
|
339
|
+
shouldSetEvent.constructor.release(shouldSetEvent);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (!wantsResponderID || wantsResponderID === responderID) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
var extracted;
|
|
346
|
+
var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant, wantsResponderID, nativeEvent, nativeEventTarget);
|
|
347
|
+
grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
348
|
+
|
|
349
|
+
EventPropagators.accumulateDirectDispatches(grantEvent);
|
|
350
|
+
if (responderID) {
|
|
351
|
+
|
|
352
|
+
var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest, responderID, nativeEvent, nativeEventTarget);
|
|
353
|
+
terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
354
|
+
EventPropagators.accumulateDirectDispatches(terminationRequestEvent);
|
|
355
|
+
var shouldSwitch = !hasDispatches(terminationRequestEvent) || executeDirectDispatch(terminationRequestEvent);
|
|
356
|
+
if (!terminationRequestEvent.isPersistent()) {
|
|
357
|
+
terminationRequestEvent.constructor.release(terminationRequestEvent);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (shouldSwitch) {
|
|
361
|
+
var terminateType = eventTypes.responderTerminate;
|
|
362
|
+
var terminateEvent = ResponderSyntheticEvent.getPooled(terminateType, responderID, nativeEvent, nativeEventTarget);
|
|
363
|
+
terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
364
|
+
EventPropagators.accumulateDirectDispatches(terminateEvent);
|
|
365
|
+
extracted = accumulate(extracted, [grantEvent, terminateEvent]);
|
|
366
|
+
changeResponder(wantsResponderID);
|
|
367
|
+
} else {
|
|
368
|
+
var rejectEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderReject, wantsResponderID, nativeEvent, nativeEventTarget);
|
|
369
|
+
rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
370
|
+
EventPropagators.accumulateDirectDispatches(rejectEvent);
|
|
371
|
+
extracted = accumulate(extracted, rejectEvent);
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
extracted = accumulate(extracted, grantEvent);
|
|
375
|
+
changeResponder(wantsResponderID);
|
|
376
|
+
}
|
|
377
|
+
return extracted;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* A transfer is a negotiation between a currently set responder and the next
|
|
382
|
+
* element to claim responder status. Any start event could trigger a transfer
|
|
383
|
+
* of responderID. Any move event could trigger a transfer.
|
|
384
|
+
*
|
|
385
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
386
|
+
* @return {boolean} True if a transfer of responder could possibly occur.
|
|
387
|
+
*/
|
|
388
|
+
function canTriggerTransfer(topLevelType, topLevelTargetID) {
|
|
389
|
+
return topLevelTargetID && (topLevelType === EventConstants.topLevelTypes.topScroll || trackedTouchCount > 0 && topLevelType === EventConstants.topLevelTypes.topSelectionChange || isStartish(topLevelType) || isMoveish(topLevelType));
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Returns whether or not this touch end event makes it such that there are no
|
|
394
|
+
* longer any touches that started inside of the current `responderID`.
|
|
395
|
+
*
|
|
396
|
+
* @param {NativeEvent} nativeEvent Native touch end event.
|
|
397
|
+
* @return {boolean} Whether or not this touch end event ends the responder.
|
|
398
|
+
*/
|
|
399
|
+
function noResponderTouches(nativeEvent) {
|
|
400
|
+
var touches = nativeEvent.touches;
|
|
401
|
+
if (!touches || touches.length === 0) {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
for (var i = 0; i < touches.length; i++) {
|
|
405
|
+
var activeTouch = touches[i];
|
|
406
|
+
var target = activeTouch.target;
|
|
407
|
+
if (target !== null && target !== undefined && target !== 0) {
|
|
408
|
+
// Is the original touch location inside of the current responder?
|
|
409
|
+
var isAncestor = ReactInstanceHandles.isAncestorIDOf(responderID, EventPluginUtils.getID(target));
|
|
410
|
+
if (isAncestor) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
var ResponderEventPlugin = {
|
|
419
|
+
|
|
420
|
+
getResponderID: function () {
|
|
421
|
+
return responderID;
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
eventTypes: eventTypes,
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* We must be resilient to `topLevelTargetID` being `undefined` on
|
|
428
|
+
* `touchMove`, or `touchEnd`. On certain platforms, this means that a native
|
|
429
|
+
* scroll has assumed control and the original touch targets are destroyed.
|
|
430
|
+
*
|
|
431
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
432
|
+
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
433
|
+
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
434
|
+
* @param {object} nativeEvent Native browser event.
|
|
435
|
+
* @return {*} An accumulation of synthetic events.
|
|
436
|
+
* @see {EventPluginHub.extractEvents}
|
|
437
|
+
*/
|
|
438
|
+
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
|
439
|
+
if (isStartish(topLevelType)) {
|
|
440
|
+
trackedTouchCount += 1;
|
|
441
|
+
} else if (isEndish(topLevelType)) {
|
|
442
|
+
trackedTouchCount -= 1;
|
|
443
|
+
!(trackedTouchCount >= 0) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Ended a touch event which was not counted in trackedTouchCount.') : invariant(false) : undefined;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent, nativeEventTarget);
|
|
447
|
+
|
|
448
|
+
var extracted = canTriggerTransfer(topLevelType, topLevelTargetID) ? setResponderAndExtractTransfer(topLevelType, topLevelTargetID, nativeEvent, nativeEventTarget) : null;
|
|
449
|
+
// Responder may or may not have transfered on a new touch start/move.
|
|
450
|
+
// Regardless, whoever is the responder after any potential transfer, we
|
|
451
|
+
// direct all touch start/move/ends to them in the form of
|
|
452
|
+
// `onResponderMove/Start/End`. These will be called for *every* additional
|
|
453
|
+
// finger that move/start/end, dispatched directly to whoever is the
|
|
454
|
+
// current responder at that moment, until the responder is "released".
|
|
455
|
+
//
|
|
456
|
+
// These multiple individual change touch events are are always bookended
|
|
457
|
+
// by `onResponderGrant`, and one of
|
|
458
|
+
// (`onResponderRelease/onResponderTerminate`).
|
|
459
|
+
var isResponderTouchStart = responderID && isStartish(topLevelType);
|
|
460
|
+
var isResponderTouchMove = responderID && isMoveish(topLevelType);
|
|
461
|
+
var isResponderTouchEnd = responderID && isEndish(topLevelType);
|
|
462
|
+
var incrementalTouch = isResponderTouchStart ? eventTypes.responderStart : isResponderTouchMove ? eventTypes.responderMove : isResponderTouchEnd ? eventTypes.responderEnd : null;
|
|
463
|
+
|
|
464
|
+
if (incrementalTouch) {
|
|
465
|
+
var gesture = ResponderSyntheticEvent.getPooled(incrementalTouch, responderID, nativeEvent, nativeEventTarget);
|
|
466
|
+
gesture.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
467
|
+
EventPropagators.accumulateDirectDispatches(gesture);
|
|
468
|
+
extracted = accumulate(extracted, gesture);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
var isResponderTerminate = responderID && topLevelType === EventConstants.topLevelTypes.topTouchCancel;
|
|
472
|
+
var isResponderRelease = responderID && !isResponderTerminate && isEndish(topLevelType) && noResponderTouches(nativeEvent);
|
|
473
|
+
var finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
|
|
474
|
+
if (finalTouch) {
|
|
475
|
+
var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch, responderID, nativeEvent, nativeEventTarget);
|
|
476
|
+
finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
477
|
+
EventPropagators.accumulateDirectDispatches(finalEvent);
|
|
478
|
+
extracted = accumulate(extracted, finalEvent);
|
|
479
|
+
changeResponder(null);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
var numberActiveTouches = ResponderTouchHistoryStore.touchHistory.numberActiveTouches;
|
|
483
|
+
if (ResponderEventPlugin.GlobalInteractionHandler && numberActiveTouches !== previousActiveTouches) {
|
|
484
|
+
ResponderEventPlugin.GlobalInteractionHandler.onChange(numberActiveTouches);
|
|
485
|
+
}
|
|
486
|
+
previousActiveTouches = numberActiveTouches;
|
|
487
|
+
|
|
488
|
+
return extracted;
|
|
489
|
+
},
|
|
490
|
+
|
|
491
|
+
GlobalResponderHandler: null,
|
|
492
|
+
GlobalInteractionHandler: null,
|
|
493
|
+
|
|
494
|
+
injection: {
|
|
495
|
+
/**
|
|
496
|
+
* @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler
|
|
497
|
+
* Object that handles any change in responder. Use this to inject
|
|
498
|
+
* integration with an existing touch handling system etc.
|
|
499
|
+
*/
|
|
500
|
+
injectGlobalResponderHandler: function (GlobalResponderHandler) {
|
|
501
|
+
ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler;
|
|
502
|
+
},
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @param {{onChange: (numberActiveTouches) => void} GlobalInteractionHandler
|
|
506
|
+
* Object that handles any change in the number of active touches.
|
|
507
|
+
*/
|
|
508
|
+
injectGlobalInteractionHandler: function (GlobalInteractionHandler) {
|
|
509
|
+
ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
module.exports = ResponderEventPlugin;
|