react 0.14.9 → 15.0.0-rc.2
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/LICENSE +1 -1
- package/addons.js +2 -0
- package/dist/react-with-addons.js +4299 -4138
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4059 -3644
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +21 -7
- package/lib/CallbackQueue.js +12 -1
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +93 -60
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +15 -36
- package/lib/DOMPropertyOperations.js +40 -52
- package/lib/Danger.js +6 -7
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +20 -64
- package/lib/EventPluginRegistry.js +23 -2
- package/lib/EventPluginUtils.js +60 -35
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +2 -3
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +16 -24
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +14 -12
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +21 -70
- package/lib/ReactComponent.js +4 -5
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +3 -3
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +146 -55
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +26 -14
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +162 -231
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +71 -22
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +9 -8
- package/lib/ReactDOMSelect.js +38 -15
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +84 -43
- package/lib/ReactDOMTextarea.js +32 -5
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +59 -19
- package/lib/ReactDefaultPerfAnalysis.js +17 -9
- package/lib/ReactElement.js +60 -21
- package/lib/ReactElementValidator.js +2 -2
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +20 -75
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +2 -2
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +4 -6
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +74 -447
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +2 -2
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +1 -24
- package/lib/ReactOwner.js +5 -4
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +16 -34
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +30 -21
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +4 -63
- package/lib/ReactUpdates.js +19 -2
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -14
- package/lib/ResponderEventPlugin.js +53 -65
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +1 -1
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +56 -16
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +97 -17
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +1 -1
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/accumulateInto.js +1 -1
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +3 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +1 -1
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +7 -9
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +5 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +6 -6
- package/lib/update.js +2 -2
- package/lib/validateDOMNesting.js +15 -11
- package/package.json +2 -2
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
package/lib/ReactUpdateQueue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2015, Facebook, Inc.
|
|
2
|
+
* Copyright 2015-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -12,11 +12,9 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
15
|
-
var ReactElement = require('./ReactElement');
|
|
16
15
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
17
16
|
var ReactUpdates = require('./ReactUpdates');
|
|
18
17
|
|
|
19
|
-
var assign = require('./Object.assign');
|
|
20
18
|
var invariant = require('fbjs/lib/invariant');
|
|
21
19
|
var warning = require('fbjs/lib/warning');
|
|
22
20
|
|
|
@@ -37,7 +35,7 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
|
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
if (process.env.NODE_ENV !== 'production') {
|
|
40
|
-
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '
|
|
38
|
+
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition (such as ' + 'within `render` or another component\'s constructor). Render methods ' + 'should be a pure function of props and state; constructor ' + 'side-effects are an anti-pattern, but can be moved to ' + '`componentWillMount`.', callerName) : undefined;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
return internalInstance;
|
|
@@ -84,7 +82,7 @@ var ReactUpdateQueue = {
|
|
|
84
82
|
* @internal
|
|
85
83
|
*/
|
|
86
84
|
enqueueCallback: function (publicInstance, callback) {
|
|
87
|
-
!(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback
|
|
85
|
+
!(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback of type ' + '%s. A function is expected', typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ? typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback) : invariant(false) : undefined;
|
|
88
86
|
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
|
|
89
87
|
|
|
90
88
|
// Previously we would throw an error if we didn't have an internal
|
|
@@ -109,7 +107,7 @@ var ReactUpdateQueue = {
|
|
|
109
107
|
},
|
|
110
108
|
|
|
111
109
|
enqueueCallbackInternal: function (internalInstance, callback) {
|
|
112
|
-
!(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback
|
|
110
|
+
!(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback of type ' + '%s. A function is expected', typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ? typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback) : invariant(false) : undefined;
|
|
113
111
|
if (internalInstance._pendingCallbacks) {
|
|
114
112
|
internalInstance._pendingCallbacks.push(callback);
|
|
115
113
|
} else {
|
|
@@ -190,63 +188,6 @@ var ReactUpdateQueue = {
|
|
|
190
188
|
enqueueUpdate(internalInstance);
|
|
191
189
|
},
|
|
192
190
|
|
|
193
|
-
/**
|
|
194
|
-
* Sets a subset of the props.
|
|
195
|
-
*
|
|
196
|
-
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
197
|
-
* @param {object} partialProps Subset of the next props.
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
enqueueSetProps: function (publicInstance, partialProps) {
|
|
201
|
-
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setProps');
|
|
202
|
-
if (!internalInstance) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps);
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
enqueueSetPropsInternal: function (internalInstance, partialProps) {
|
|
209
|
-
var topLevelWrapper = internalInstance._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
|
-
|
|
212
|
-
// Merge with the pending element if it exists, otherwise with existing
|
|
213
|
-
// element props.
|
|
214
|
-
var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
|
|
215
|
-
var element = wrapElement.props;
|
|
216
|
-
var props = assign({}, element.props, partialProps);
|
|
217
|
-
topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
|
|
218
|
-
|
|
219
|
-
enqueueUpdate(topLevelWrapper);
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Replaces all of the props.
|
|
224
|
-
*
|
|
225
|
-
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
226
|
-
* @param {object} props New props.
|
|
227
|
-
* @internal
|
|
228
|
-
*/
|
|
229
|
-
enqueueReplaceProps: function (publicInstance, props) {
|
|
230
|
-
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceProps');
|
|
231
|
-
if (!internalInstance) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props);
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
enqueueReplacePropsInternal: function (internalInstance, props) {
|
|
238
|
-
var topLevelWrapper = internalInstance._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
|
-
|
|
241
|
-
// Merge with the pending element if it exists, otherwise with existing
|
|
242
|
-
// element props.
|
|
243
|
-
var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
|
|
244
|
-
var element = wrapElement.props;
|
|
245
|
-
topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
|
|
246
|
-
|
|
247
|
-
enqueueUpdate(topLevelWrapper);
|
|
248
|
-
},
|
|
249
|
-
|
|
250
191
|
enqueueElementInternal: function (internalInstance, newElement) {
|
|
251
192
|
internalInstance._pendingElement = newElement;
|
|
252
193
|
enqueueUpdate(internalInstance);
|
package/lib/ReactUpdates.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
var CallbackQueue = require('./CallbackQueue');
|
|
15
15
|
var PooledClass = require('./PooledClass');
|
|
16
|
+
var ReactFeatureFlags = require('./ReactFeatureFlags');
|
|
16
17
|
var ReactPerf = require('./ReactPerf');
|
|
17
18
|
var ReactReconciler = require('./ReactReconciler');
|
|
18
19
|
var Transaction = require('./Transaction');
|
|
@@ -64,7 +65,8 @@ function ReactUpdatesFlushTransaction() {
|
|
|
64
65
|
this.reinitializeTransaction();
|
|
65
66
|
this.dirtyComponentsLength = null;
|
|
66
67
|
this.callbackQueue = CallbackQueue.getPooled();
|
|
67
|
-
this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled(
|
|
68
|
+
this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled(
|
|
69
|
+
/* useCreateElement */true);
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
|
|
@@ -126,8 +128,23 @@ function runBatchedUpdates(transaction) {
|
|
|
126
128
|
var callbacks = component._pendingCallbacks;
|
|
127
129
|
component._pendingCallbacks = null;
|
|
128
130
|
|
|
131
|
+
var markerName;
|
|
132
|
+
if (ReactFeatureFlags.logTopLevelRenders) {
|
|
133
|
+
var namedComponent = component;
|
|
134
|
+
// Duck type TopLevelWrapper. This is probably always true.
|
|
135
|
+
if (component._currentElement.props === component._renderedComponent._currentElement) {
|
|
136
|
+
namedComponent = component._renderedComponent;
|
|
137
|
+
}
|
|
138
|
+
markerName = 'React update: ' + namedComponent.getName();
|
|
139
|
+
console.time(markerName);
|
|
140
|
+
}
|
|
141
|
+
|
|
129
142
|
ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction);
|
|
130
143
|
|
|
144
|
+
if (markerName) {
|
|
145
|
+
console.timeEnd(markerName);
|
|
146
|
+
}
|
|
147
|
+
|
|
131
148
|
if (callbacks) {
|
|
132
149
|
for (var j = 0; j < callbacks.length; j++) {
|
|
133
150
|
transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance());
|
package/lib/ReactVersion.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
module.exports = '0.
|
|
14
|
+
module.exports = '15.0.0-rc.2';
|
package/lib/ReactWithAddons.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -24,14 +24,9 @@ var ReactComponentWithPureRenderMixin = require('./ReactComponentWithPureRenderM
|
|
|
24
24
|
var ReactCSSTransitionGroup = require('./ReactCSSTransitionGroup');
|
|
25
25
|
var ReactFragment = require('./ReactFragment');
|
|
26
26
|
var ReactTransitionGroup = require('./ReactTransitionGroup');
|
|
27
|
-
var ReactUpdates = require('./ReactUpdates');
|
|
28
27
|
|
|
29
|
-
var cloneWithProps = require('./cloneWithProps');
|
|
30
28
|
var shallowCompare = require('./shallowCompare');
|
|
31
29
|
var update = require('./update');
|
|
32
|
-
var warning = require('fbjs/lib/warning');
|
|
33
|
-
|
|
34
|
-
var warnedAboutBatchedUpdates = false;
|
|
35
30
|
|
|
36
31
|
React.addons = {
|
|
37
32
|
CSSTransitionGroup: ReactCSSTransitionGroup,
|
|
@@ -39,14 +34,6 @@ React.addons = {
|
|
|
39
34
|
PureRenderMixin: ReactComponentWithPureRenderMixin,
|
|
40
35
|
TransitionGroup: ReactTransitionGroup,
|
|
41
36
|
|
|
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
|
-
},
|
|
49
|
-
cloneWithProps: cloneWithProps,
|
|
50
37
|
createFragment: ReactFragment.create,
|
|
51
38
|
shallowCompare: shallowCompare,
|
|
52
39
|
update: update
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
var EventConstants = require('./EventConstants');
|
|
15
15
|
var EventPluginUtils = require('./EventPluginUtils');
|
|
16
16
|
var EventPropagators = require('./EventPropagators');
|
|
17
|
-
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
18
17
|
var ResponderSyntheticEvent = require('./ResponderSyntheticEvent');
|
|
19
18
|
var ResponderTouchHistoryStore = require('./ResponderTouchHistoryStore');
|
|
20
19
|
|
|
@@ -30,14 +29,14 @@ var hasDispatches = EventPluginUtils.hasDispatches;
|
|
|
30
29
|
var executeDispatchesInOrderStopAtTrue = EventPluginUtils.executeDispatchesInOrderStopAtTrue;
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
34
|
-
* indicated explicitly by relevant callbacks.
|
|
32
|
+
* Instance of element that should respond to touch/move types of interactions,
|
|
33
|
+
* as indicated explicitly by relevant callbacks.
|
|
35
34
|
*/
|
|
36
|
-
var
|
|
35
|
+
var responderInst = null;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* Count of current touches. A textInput should become responder iff the
|
|
40
|
-
*
|
|
39
|
+
* selection changes while there is a touch on the screen.
|
|
41
40
|
*/
|
|
42
41
|
var trackedTouchCount = 0;
|
|
43
42
|
|
|
@@ -46,11 +45,11 @@ var trackedTouchCount = 0;
|
|
|
46
45
|
*/
|
|
47
46
|
var previousActiveTouches = 0;
|
|
48
47
|
|
|
49
|
-
var changeResponder = function (
|
|
50
|
-
var
|
|
51
|
-
|
|
48
|
+
var changeResponder = function (nextResponderInst, blockNativeResponder) {
|
|
49
|
+
var oldResponderInst = responderInst;
|
|
50
|
+
responderInst = nextResponderInst;
|
|
52
51
|
if (ResponderEventPlugin.GlobalResponderHandler !== null) {
|
|
53
|
-
ResponderEventPlugin.GlobalResponderHandler.onChange(
|
|
52
|
+
ResponderEventPlugin.GlobalResponderHandler.onChange(oldResponderInst, nextResponderInst, blockNativeResponder);
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
55
|
|
|
@@ -69,7 +68,7 @@ var eventTypes = {
|
|
|
69
68
|
/**
|
|
70
69
|
* On a `scroll`, is it desired that this element become the responder? This
|
|
71
70
|
* is usually not needed, but should be used to retroactively infer that a
|
|
72
|
-
* `touchStart` had
|
|
71
|
+
* `touchStart` had occurred during momentum scroll. During a momentum scroll,
|
|
73
72
|
* a touch start will be immediately followed by a scroll event if the view is
|
|
74
73
|
* currently scrolling.
|
|
75
74
|
*
|
|
@@ -132,7 +131,7 @@ var eventTypes = {
|
|
|
132
131
|
* immediately to indicate so, either by highlighting or moving accordingly.
|
|
133
132
|
* - To be the responder means, that touches are exclusively important to that
|
|
134
133
|
* responder view, and no other view.
|
|
135
|
-
* - While touches are still
|
|
134
|
+
* - While touches are still occurring, the responder lock can be transferred to
|
|
136
135
|
* a new view, but only to increasingly "higher" views (meaning ancestors of
|
|
137
136
|
* the current responder).
|
|
138
137
|
*
|
|
@@ -145,7 +144,7 @@ var eventTypes = {
|
|
|
145
144
|
* - If nothing is currently the responder, the "appropriate place" is the
|
|
146
145
|
* initiating event's `targetID`.
|
|
147
146
|
* - If something *is* already the responder, the "appropriate place" is the
|
|
148
|
-
* first common ancestor of the event target and the current `
|
|
147
|
+
* first common ancestor of the event target and the current `responderInst`.
|
|
149
148
|
* - Some negotiation happens: See the timing diagram below.
|
|
150
149
|
* - Scrolled views automatically become responder. The reasoning is that a
|
|
151
150
|
* platform scroll view that isn't built on top of the responder system has
|
|
@@ -153,8 +152,8 @@ var eventTypes = {
|
|
|
153
152
|
* interaction is no longer locked to it - the system has taken over.
|
|
154
153
|
*
|
|
155
154
|
* - Responder being released:
|
|
156
|
-
* As soon as no more touches that *started* inside of
|
|
157
|
-
* *current*
|
|
155
|
+
* As soon as no more touches that *started* inside of descendants of the
|
|
156
|
+
* *current* responderInst, an `onResponderRelease` event is dispatched to the
|
|
158
157
|
* current responder, and the responder lock is released.
|
|
159
158
|
*
|
|
160
159
|
* TODO:
|
|
@@ -310,23 +309,19 @@ to return true:wantsResponderID| |
|
|
|
310
309
|
* - `touchStartCapture` (`EventPluginHub` dispatches as usual)
|
|
311
310
|
* - `touchStart` (`EventPluginHub` dispatches as usual)
|
|
312
311
|
* - `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
312
|
*/
|
|
319
|
-
|
|
313
|
+
|
|
314
|
+
function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
320
315
|
var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === EventConstants.topLevelTypes.topSelectionChange ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
|
|
321
316
|
|
|
322
|
-
// TODO: stop one short of the
|
|
323
|
-
var bubbleShouldSetFrom = !
|
|
317
|
+
// TODO: stop one short of the current responder.
|
|
318
|
+
var bubbleShouldSetFrom = !responderInst ? targetInst : EventPluginUtils.getLowestCommonAncestor(responderInst, targetInst);
|
|
324
319
|
|
|
325
320
|
// When capturing/bubbling the "shouldSet" event, we want to skip the target
|
|
326
321
|
// (deepest ID) if it happens to be the current responder. The reasoning:
|
|
327
322
|
// It's strange to get an `onMoveShouldSetResponder` when you're *already*
|
|
328
323
|
// the responder.
|
|
329
|
-
var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom ===
|
|
324
|
+
var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst;
|
|
330
325
|
var shouldSetEvent = ResponderSyntheticEvent.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
|
|
331
326
|
shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
332
327
|
if (skipOverBubbleShouldSetFrom) {
|
|
@@ -334,23 +329,23 @@ function setResponderAndExtractTransfer(topLevelType, topLevelTargetID, nativeEv
|
|
|
334
329
|
} else {
|
|
335
330
|
EventPropagators.accumulateTwoPhaseDispatches(shouldSetEvent);
|
|
336
331
|
}
|
|
337
|
-
var
|
|
332
|
+
var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
|
|
338
333
|
if (!shouldSetEvent.isPersistent()) {
|
|
339
334
|
shouldSetEvent.constructor.release(shouldSetEvent);
|
|
340
335
|
}
|
|
341
336
|
|
|
342
|
-
if (!
|
|
337
|
+
if (!wantsResponderInst || wantsResponderInst === responderInst) {
|
|
343
338
|
return null;
|
|
344
339
|
}
|
|
345
340
|
var extracted;
|
|
346
|
-
var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant,
|
|
341
|
+
var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
|
|
347
342
|
grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
348
343
|
|
|
349
344
|
EventPropagators.accumulateDirectDispatches(grantEvent);
|
|
350
345
|
var blockNativeResponder = executeDirectDispatch(grantEvent) === true;
|
|
351
|
-
if (
|
|
346
|
+
if (responderInst) {
|
|
352
347
|
|
|
353
|
-
var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest,
|
|
348
|
+
var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
|
|
354
349
|
terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
355
350
|
EventPropagators.accumulateDirectDispatches(terminationRequestEvent);
|
|
356
351
|
var shouldSwitch = !hasDispatches(terminationRequestEvent) || executeDirectDispatch(terminationRequestEvent);
|
|
@@ -359,21 +354,20 @@ function setResponderAndExtractTransfer(topLevelType, topLevelTargetID, nativeEv
|
|
|
359
354
|
}
|
|
360
355
|
|
|
361
356
|
if (shouldSwitch) {
|
|
362
|
-
var
|
|
363
|
-
var terminateEvent = ResponderSyntheticEvent.getPooled(terminateType, responderID, nativeEvent, nativeEventTarget);
|
|
357
|
+
var terminateEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget);
|
|
364
358
|
terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
365
359
|
EventPropagators.accumulateDirectDispatches(terminateEvent);
|
|
366
360
|
extracted = accumulate(extracted, [grantEvent, terminateEvent]);
|
|
367
|
-
changeResponder(
|
|
361
|
+
changeResponder(wantsResponderInst, blockNativeResponder);
|
|
368
362
|
} else {
|
|
369
|
-
var rejectEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderReject,
|
|
363
|
+
var rejectEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderReject, wantsResponderInst, nativeEvent, nativeEventTarget);
|
|
370
364
|
rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
371
365
|
EventPropagators.accumulateDirectDispatches(rejectEvent);
|
|
372
366
|
extracted = accumulate(extracted, rejectEvent);
|
|
373
367
|
}
|
|
374
368
|
} else {
|
|
375
369
|
extracted = accumulate(extracted, grantEvent);
|
|
376
|
-
changeResponder(
|
|
370
|
+
changeResponder(wantsResponderInst, blockNativeResponder);
|
|
377
371
|
}
|
|
378
372
|
return extracted;
|
|
379
373
|
}
|
|
@@ -381,22 +375,22 @@ function setResponderAndExtractTransfer(topLevelType, topLevelTargetID, nativeEv
|
|
|
381
375
|
/**
|
|
382
376
|
* A transfer is a negotiation between a currently set responder and the next
|
|
383
377
|
* element to claim responder status. Any start event could trigger a transfer
|
|
384
|
-
* of
|
|
378
|
+
* of responderInst. Any move event could trigger a transfer.
|
|
385
379
|
*
|
|
386
380
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
387
381
|
* @return {boolean} True if a transfer of responder could possibly occur.
|
|
388
382
|
*/
|
|
389
|
-
function canTriggerTransfer(topLevelType,
|
|
390
|
-
return
|
|
391
|
-
// responderIgnoreScroll: We are trying to migrate away from specifically
|
|
392
|
-
// events here and responderIgnoreScroll indicates we
|
|
393
|
-
// canceling touch events instead
|
|
383
|
+
function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
|
|
384
|
+
return topLevelInst && (
|
|
385
|
+
// responderIgnoreScroll: We are trying to migrate away from specifically
|
|
386
|
+
// tracking native scroll events here and responderIgnoreScroll indicates we
|
|
387
|
+
// will send topTouchCancel to handle canceling touch events instead
|
|
394
388
|
topLevelType === EventConstants.topLevelTypes.topScroll && !nativeEvent.responderIgnoreScroll || trackedTouchCount > 0 && topLevelType === EventConstants.topLevelTypes.topSelectionChange || isStartish(topLevelType) || isMoveish(topLevelType));
|
|
395
389
|
}
|
|
396
390
|
|
|
397
391
|
/**
|
|
398
392
|
* Returns whether or not this touch end event makes it such that there are no
|
|
399
|
-
* longer any touches that started inside of the current `
|
|
393
|
+
* longer any touches that started inside of the current `responderInst`.
|
|
400
394
|
*
|
|
401
395
|
* @param {NativeEvent} nativeEvent Native touch end event.
|
|
402
396
|
* @return {boolean} Whether or not this touch end event ends the responder.
|
|
@@ -411,8 +405,8 @@ function noResponderTouches(nativeEvent) {
|
|
|
411
405
|
var target = activeTouch.target;
|
|
412
406
|
if (target !== null && target !== undefined && target !== 0) {
|
|
413
407
|
// Is the original touch location inside of the current responder?
|
|
414
|
-
var
|
|
415
|
-
if (isAncestor) {
|
|
408
|
+
var targetInst = EventPluginUtils.getInstanceFromNode(target);
|
|
409
|
+
if (EventPluginUtils.isAncestor(responderInst, targetInst)) {
|
|
416
410
|
return false;
|
|
417
411
|
}
|
|
418
412
|
}
|
|
@@ -422,25 +416,19 @@ function noResponderTouches(nativeEvent) {
|
|
|
422
416
|
|
|
423
417
|
var ResponderEventPlugin = {
|
|
424
418
|
|
|
425
|
-
|
|
426
|
-
|
|
419
|
+
/* For unit testing only */
|
|
420
|
+
_getResponderID: function () {
|
|
421
|
+
return responderInst ? responderInst._rootNodeID : null;
|
|
427
422
|
},
|
|
428
423
|
|
|
429
424
|
eventTypes: eventTypes,
|
|
430
425
|
|
|
431
426
|
/**
|
|
432
|
-
* We must be resilient to `
|
|
433
|
-
* `
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
437
|
-
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
438
|
-
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
439
|
-
* @param {object} nativeEvent Native browser event.
|
|
440
|
-
* @return {*} An accumulation of synthetic events.
|
|
441
|
-
* @see {EventPluginHub.extractEvents}
|
|
427
|
+
* We must be resilient to `targetInst` being `null` on `touchMove` or
|
|
428
|
+
* `touchEnd`. On certain platforms, this means that a native scroll has
|
|
429
|
+
* assumed control and the original touch targets are destroyed.
|
|
442
430
|
*/
|
|
443
|
-
extractEvents: function (topLevelType,
|
|
431
|
+
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
444
432
|
if (isStartish(topLevelType)) {
|
|
445
433
|
trackedTouchCount += 1;
|
|
446
434
|
} else if (isEndish(topLevelType)) {
|
|
@@ -450,8 +438,8 @@ var ResponderEventPlugin = {
|
|
|
450
438
|
|
|
451
439
|
ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent, nativeEventTarget);
|
|
452
440
|
|
|
453
|
-
var extracted = canTriggerTransfer(topLevelType,
|
|
454
|
-
// Responder may or may not have
|
|
441
|
+
var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null;
|
|
442
|
+
// Responder may or may not have transferred on a new touch start/move.
|
|
455
443
|
// Regardless, whoever is the responder after any potential transfer, we
|
|
456
444
|
// direct all touch start/move/ends to them in the form of
|
|
457
445
|
// `onResponderMove/Start/End`. These will be called for *every* additional
|
|
@@ -461,23 +449,23 @@ var ResponderEventPlugin = {
|
|
|
461
449
|
// These multiple individual change touch events are are always bookended
|
|
462
450
|
// by `onResponderGrant`, and one of
|
|
463
451
|
// (`onResponderRelease/onResponderTerminate`).
|
|
464
|
-
var isResponderTouchStart =
|
|
465
|
-
var isResponderTouchMove =
|
|
466
|
-
var isResponderTouchEnd =
|
|
452
|
+
var isResponderTouchStart = responderInst && isStartish(topLevelType);
|
|
453
|
+
var isResponderTouchMove = responderInst && isMoveish(topLevelType);
|
|
454
|
+
var isResponderTouchEnd = responderInst && isEndish(topLevelType);
|
|
467
455
|
var incrementalTouch = isResponderTouchStart ? eventTypes.responderStart : isResponderTouchMove ? eventTypes.responderMove : isResponderTouchEnd ? eventTypes.responderEnd : null;
|
|
468
456
|
|
|
469
457
|
if (incrementalTouch) {
|
|
470
|
-
var gesture = ResponderSyntheticEvent.getPooled(incrementalTouch,
|
|
458
|
+
var gesture = ResponderSyntheticEvent.getPooled(incrementalTouch, responderInst, nativeEvent, nativeEventTarget);
|
|
471
459
|
gesture.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
472
460
|
EventPropagators.accumulateDirectDispatches(gesture);
|
|
473
461
|
extracted = accumulate(extracted, gesture);
|
|
474
462
|
}
|
|
475
463
|
|
|
476
|
-
var isResponderTerminate =
|
|
477
|
-
var isResponderRelease =
|
|
464
|
+
var isResponderTerminate = responderInst && topLevelType === EventConstants.topLevelTypes.topTouchCancel;
|
|
465
|
+
var isResponderRelease = responderInst && !isResponderTerminate && isEndish(topLevelType) && noResponderTouches(nativeEvent);
|
|
478
466
|
var finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
|
|
479
467
|
if (finalTouch) {
|
|
480
|
-
var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch,
|
|
468
|
+
var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
|
|
481
469
|
finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
482
470
|
EventPropagators.accumulateDirectDispatches(finalEvent);
|
|
483
471
|
extracted = accumulate(extracted, finalEvent);
|