react 15.0.0-rc.2 → 15.0.2-alpha.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/dist/react-with-addons.js +1250 -1105
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +1116 -1001
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +31 -15
- package/lib/CallbackQueue.js +4 -3
- package/lib/DOMChildrenOperations.js +0 -3
- package/lib/DOMProperty.js +3 -3
- package/lib/DOMPropertyOperations.js +1 -1
- package/lib/Danger.js +8 -8
- package/lib/EventPluginHub.js +2 -2
- package/lib/EventPluginRegistry.js +7 -7
- package/lib/EventPluginUtils.js +6 -6
- package/lib/EventPropagators.js +1 -1
- package/lib/FallbackCompositionState.js +3 -2
- package/lib/IOSDefaultEventPluginOrder.js +16 -0
- package/lib/IOSNativeBridgeEventPlugin.js +57 -0
- package/lib/LinkedValueUtils.js +4 -4
- package/lib/NativeMethodsMixin.js +165 -0
- package/lib/OrderedMap.js +16 -15
- package/lib/PanResponder.js +362 -0
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +68 -9
- package/lib/ReactBrowserEventEmitter.js +3 -2
- package/lib/ReactCSSTransitionGroup.js +3 -3
- package/lib/ReactChildReconciler.js +1 -1
- package/lib/ReactClass.js +24 -23
- package/lib/ReactComponent.js +5 -5
- package/lib/ReactComponentEnvironment.js +1 -1
- package/lib/ReactCompositeComponent.js +26 -25
- package/lib/ReactDOM.js +3 -3
- package/lib/ReactDOMComponent.js +34 -22
- package/lib/ReactDOMComponentTree.js +3 -3
- package/lib/ReactDOMDebugTool.js +1 -1
- package/lib/ReactDOMEmptyComponent.js +3 -3
- package/lib/ReactDOMInput.js +11 -10
- package/lib/ReactDOMOption.js +15 -4
- package/lib/ReactDOMSelect.js +8 -7
- package/lib/ReactDOMTextComponent.js +4 -3
- package/lib/ReactDOMTextarea.js +10 -9
- package/lib/ReactDOMTreeTraversal.js +5 -5
- package/lib/ReactDOMUnknownPropertyDevtool.js +2 -2
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +1 -1
- package/lib/ReactDefaultBatchingStrategy.js +3 -2
- package/lib/ReactDefaultPerf.js +46 -7
- package/lib/ReactDefaultPerfAnalysis.js +7 -7
- package/lib/ReactElement.js +5 -4
- package/lib/ReactElementValidator.js +7 -7
- package/lib/ReactEventListener.js +3 -2
- package/lib/ReactFragment.js +4 -4
- package/lib/ReactInstanceHandles.js +6 -6
- package/lib/ReactInvalidSetStateWarningDevTool.js +1 -1
- package/lib/ReactMount.js +15 -14
- package/lib/ReactMultiChild.js +2 -2
- package/lib/ReactNative.js +71 -0
- package/lib/ReactNativeAttributePayload.js +397 -0
- package/lib/ReactNativeBaseComponent.js +196 -0
- package/lib/ReactNativeComponent.js +4 -3
- package/lib/ReactNativeComponentEnvironment.js +38 -0
- package/lib/ReactNativeComponentTree.js +66 -0
- package/lib/ReactNativeContainerInfo.js +21 -0
- package/lib/ReactNativeDOMIDOperations.js +83 -0
- package/lib/ReactNativeDefaultInjection.js +99 -0
- package/lib/ReactNativeEventEmitter.js +183 -0
- package/lib/ReactNativeGlobalInteractionHandler.js +33 -0
- package/lib/ReactNativeGlobalResponderHandler.js +25 -0
- package/lib/ReactNativeMount.js +190 -0
- package/lib/ReactNativePropRegistry.js +52 -0
- package/lib/ReactNativeReconcileTransaction.js +100 -0
- package/lib/ReactNativeTagHandles.js +54 -0
- package/lib/ReactNativeTextComponent.js +70 -0
- package/lib/ReactNativeTreeTraversal.js +127 -0
- package/lib/ReactNodeTypes.js +1 -1
- package/lib/ReactNoopUpdateQueue.js +1 -1
- package/lib/ReactOwner.js +2 -2
- package/lib/ReactPropTransferer.js +4 -3
- package/lib/ReactReconcileTransaction.js +3 -3
- package/lib/ReactServerRendering.js +2 -2
- package/lib/ReactServerRenderingTransaction.js +3 -3
- package/lib/ReactSimpleEmptyComponent.js +3 -3
- package/lib/ReactTestUtils.js +18 -8
- package/lib/ReactTransitionGroup.js +3 -2
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +23 -6
- package/lib/ReactUpdates.js +10 -9
- package/lib/ReactVersion.js +1 -1
- package/lib/ReactWithAddons.js +0 -7
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +1 -1
- package/lib/ResponderTouchHistoryStore.js +4 -4
- package/lib/SimpleEventPlugin.js +1 -1
- package/lib/SyntheticEvent.js +7 -6
- package/lib/TouchHistoryMath.js +99 -0
- package/lib/Transaction.js +2 -2
- package/lib/accumulate.js +1 -1
- package/lib/accumulateInto.js +1 -1
- package/lib/createReactNativeComponentClass.js +42 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +4 -3
- package/lib/findDOMNode.js +3 -3
- package/lib/findNodeHandle.js +89 -0
- package/lib/flattenChildren.js +1 -1
- package/lib/instantiateReactComponent.js +6 -5
- package/lib/onlyChild.js +1 -1
- package/lib/reactComponentExpect.js +4 -3
- package/lib/setInnerHTML.js +1 -0
- package/lib/traverseAllChildren.js +2 -2
- package/lib/update.js +14 -13
- package/lib/validateDOMNesting.js +5 -4
- package/package.json +5 -4
- package/addons.js +0 -15
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactDOM.native.js +0 -12
- package/lib/ReactIsomorphic.js +0 -74
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @providesModule TouchHistoryMath
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
var TouchHistoryMath = {
|
|
8
|
+
/**
|
|
9
|
+
* This code is optimized and not intended to look beautiful. This allows
|
|
10
|
+
* computing of touch centroids that have moved after `touchesChangedAfter`
|
|
11
|
+
* timeStamp. You can compute the current centroid involving all touches
|
|
12
|
+
* moves after `touchesChangedAfter`, or you can compute the previous
|
|
13
|
+
* centroid of all touches that were moved after `touchesChangedAfter`.
|
|
14
|
+
*
|
|
15
|
+
* @param {TouchHistoryMath} touchHistory Standard Responder touch track
|
|
16
|
+
* data.
|
|
17
|
+
* @param {number} touchesChangedAfter timeStamp after which moved touches
|
|
18
|
+
* are considered "actively moving" - not just "active".
|
|
19
|
+
* @param {boolean} isXAxis Consider `x` dimension vs. `y` dimension.
|
|
20
|
+
* @param {boolean} ofCurrent Compute current centroid for actively moving
|
|
21
|
+
* touches vs. previous centroid of now actively moving touches.
|
|
22
|
+
* @return {number} value of centroid in specified dimension.
|
|
23
|
+
*/
|
|
24
|
+
centroidDimension: function (touchHistory, touchesChangedAfter, isXAxis, ofCurrent) {
|
|
25
|
+
var touchBank = touchHistory.touchBank;
|
|
26
|
+
var total = 0;
|
|
27
|
+
var count = 0;
|
|
28
|
+
|
|
29
|
+
var oneTouchData = touchHistory.numberActiveTouches === 1 ? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch] : null;
|
|
30
|
+
|
|
31
|
+
if (oneTouchData !== null) {
|
|
32
|
+
if (oneTouchData.touchActive && oneTouchData.currentTimeStamp > touchesChangedAfter) {
|
|
33
|
+
total += ofCurrent && isXAxis ? oneTouchData.currentPageX : ofCurrent && !isXAxis ? oneTouchData.currentPageY : !ofCurrent && isXAxis ? oneTouchData.previousPageX : oneTouchData.previousPageY;
|
|
34
|
+
count = 1;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
for (var i = 0; i < touchBank.length; i++) {
|
|
38
|
+
var touchTrack = touchBank[i];
|
|
39
|
+
if (touchTrack !== null && touchTrack !== undefined && touchTrack.touchActive && touchTrack.currentTimeStamp >= touchesChangedAfter) {
|
|
40
|
+
var toAdd; // Yuck, program temporarily in invalid state.
|
|
41
|
+
if (ofCurrent && isXAxis) {
|
|
42
|
+
toAdd = touchTrack.currentPageX;
|
|
43
|
+
} else if (ofCurrent && !isXAxis) {
|
|
44
|
+
toAdd = touchTrack.currentPageY;
|
|
45
|
+
} else if (!ofCurrent && isXAxis) {
|
|
46
|
+
toAdd = touchTrack.previousPageX;
|
|
47
|
+
} else {
|
|
48
|
+
toAdd = touchTrack.previousPageY;
|
|
49
|
+
}
|
|
50
|
+
total += toAdd;
|
|
51
|
+
count++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return count > 0 ? total / count : TouchHistoryMath.noCentroid;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
currentCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
|
|
59
|
+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
|
|
60
|
+
true // ofCurrent
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
currentCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
|
|
65
|
+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
|
|
66
|
+
true // ofCurrent
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
previousCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
|
|
71
|
+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
|
|
72
|
+
false // ofCurrent
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
previousCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
|
|
77
|
+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
|
|
78
|
+
false // ofCurrent
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
currentCentroidX: function (touchHistory) {
|
|
83
|
+
return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
|
|
84
|
+
true, // isXAxis
|
|
85
|
+
true // ofCurrent
|
|
86
|
+
);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
currentCentroidY: function (touchHistory) {
|
|
90
|
+
return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
|
|
91
|
+
false, // isXAxis
|
|
92
|
+
true // ofCurrent
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
noCentroid: -1
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
module.exports = TouchHistoryMath;
|
package/lib/Transaction.js
CHANGED
|
@@ -122,7 +122,7 @@ var Mixin = {
|
|
|
122
122
|
* @return {*} Return value from `method`.
|
|
123
123
|
*/
|
|
124
124
|
perform: function (method, scope, a, b, c, d, e, f) {
|
|
125
|
-
!!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) :
|
|
125
|
+
!!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) : void 0;
|
|
126
126
|
var errorThrown;
|
|
127
127
|
var ret;
|
|
128
128
|
try {
|
|
@@ -186,7 +186,7 @@ var Mixin = {
|
|
|
186
186
|
* invoked).
|
|
187
187
|
*/
|
|
188
188
|
closeAll: function (startIndex) {
|
|
189
|
-
!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) :
|
|
189
|
+
!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) : void 0;
|
|
190
190
|
var transactionWrappers = this.transactionWrappers;
|
|
191
191
|
for (var i = startIndex; i < transactionWrappers.length; i++) {
|
|
192
192
|
var wrapper = transactionWrappers[i];
|
package/lib/accumulate.js
CHANGED
|
@@ -21,7 +21,7 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
21
21
|
* @return {*|array<*>} An accumulation of items.
|
|
22
22
|
*/
|
|
23
23
|
function accumulate(current, next) {
|
|
24
|
-
!(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulate(...): Accumulated items must be not be null or undefined.') : invariant(false) :
|
|
24
|
+
!(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulate(...): Accumulated items must be not be null or undefined.') : invariant(false) : void 0;
|
|
25
25
|
if (current == null) {
|
|
26
26
|
return next;
|
|
27
27
|
} else {
|
package/lib/accumulateInto.js
CHANGED
|
@@ -28,7 +28,7 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
function accumulateInto(current, next) {
|
|
31
|
-
!(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) :
|
|
31
|
+
!(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) : void 0;
|
|
32
32
|
if (current == null) {
|
|
33
33
|
return next;
|
|
34
34
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-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 createReactNativeComponentClass
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
var ReactNativeBaseComponent = require('./ReactNativeBaseComponent');
|
|
16
|
+
|
|
17
|
+
// See also ReactNativeBaseComponent
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} config iOS View configuration.
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
var createReactNativeComponentClass = function (viewConfig) {
|
|
25
|
+
var Constructor = function (element) {
|
|
26
|
+
this._currentElement = element;
|
|
27
|
+
this._topLevelWrapper = null;
|
|
28
|
+
this._nativeParent = null;
|
|
29
|
+
this._nativeContainerInfo = null;
|
|
30
|
+
this._rootNodeID = null;
|
|
31
|
+
this._renderedChildren = null;
|
|
32
|
+
};
|
|
33
|
+
Constructor.displayName = viewConfig.uiViewClassName;
|
|
34
|
+
Constructor.viewConfig = viewConfig;
|
|
35
|
+
Constructor.propTypes = viewConfig.propTypes;
|
|
36
|
+
Constructor.prototype = new ReactNativeBaseComponent(viewConfig);
|
|
37
|
+
Constructor.prototype.constructor = Constructor;
|
|
38
|
+
|
|
39
|
+
return Constructor;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = createReactNativeComponentClass;
|
|
@@ -65,7 +65,7 @@ function dangerousStyleValue(name, value, component) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
if (!warned) {
|
|
68
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'a `%s` tag (owner: `%s`) was passed a numeric string value ' + 'for CSS property `%s` (value: `%s`) which will be treated ' + 'as a unitless number in a future version of React.', component._currentElement.type, ownerName || 'unknown', name, value) :
|
|
68
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'a `%s` tag (owner: `%s`) was passed a numeric string value ' + 'for CSS property `%s` (value: `%s`) which will be treated ' + 'as a unitless number in a future version of React.', component._currentElement.type, ownerName || 'unknown', name, value) : void 0;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
package/lib/deprecated.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
15
16
|
var warning = require('fbjs/lib/warning');
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -34,14 +35,14 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
|
|
|
34
35
|
// Require examples in this string must be split to prevent React's
|
|
35
36
|
// build tools from mistaking them for real requires.
|
|
36
37
|
// Otherwise the build tools will attempt to build a '%s' module.
|
|
37
|
-
'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) :
|
|
38
|
+
'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : void 0;
|
|
38
39
|
/* eslint-enable no-useless-concat */
|
|
39
40
|
warned = true;
|
|
40
41
|
return fn.apply(ctx, arguments);
|
|
41
42
|
};
|
|
42
43
|
// We need to make sure all properties of the original fn are copied over.
|
|
43
44
|
// In particular, this is needed to support PropTypes
|
|
44
|
-
return
|
|
45
|
+
return _assign(newFn, fn);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
return fn;
|
package/lib/findDOMNode.js
CHANGED
|
@@ -29,7 +29,7 @@ function findDOMNode(componentOrElement) {
|
|
|
29
29
|
if (process.env.NODE_ENV !== 'production') {
|
|
30
30
|
var owner = ReactCurrentOwner.current;
|
|
31
31
|
if (owner !== null) {
|
|
32
|
-
process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing findDOMNode inside its render(). ' + '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') :
|
|
32
|
+
process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing findDOMNode inside its render(). ' + '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') : void 0;
|
|
33
33
|
owner._warnedAboutRefsInRender = true;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -47,9 +47,9 @@ function findDOMNode(componentOrElement) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (typeof componentOrElement.render === 'function') {
|
|
50
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) :
|
|
50
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) : void 0;
|
|
51
51
|
} else {
|
|
52
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) :
|
|
52
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) : void 0;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-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 findNodeHandle
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
16
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
17
|
+
|
|
18
|
+
var invariant = require('fbjs/lib/invariant');
|
|
19
|
+
var warning = require('fbjs/lib/warning');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* ReactNative vs ReactWeb
|
|
23
|
+
* -----------------------
|
|
24
|
+
* React treats some pieces of data opaquely. This means that the information
|
|
25
|
+
* is first class (it can be passed around), but cannot be inspected. This
|
|
26
|
+
* allows us to build infrastructure that reasons about resources, without
|
|
27
|
+
* making assumptions about the nature of those resources, and this allows that
|
|
28
|
+
* infra to be shared across multiple platforms, where the resources are very
|
|
29
|
+
* different. General infra (such as `ReactMultiChild`) reasons opaquely about
|
|
30
|
+
* the data, but platform specific code (such as `ReactNativeBaseComponent`) can
|
|
31
|
+
* make assumptions about the data.
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* `rootNodeID`, uniquely identifies a position in the generated native view
|
|
35
|
+
* tree. Many layers of composite components (created with `React.createClass`)
|
|
36
|
+
* can all share the same `rootNodeID`.
|
|
37
|
+
*
|
|
38
|
+
* `nodeHandle`: A sufficiently unambiguous way to refer to a lower level
|
|
39
|
+
* resource (dom node, native view etc). The `rootNodeID` is sufficient for web
|
|
40
|
+
* `nodeHandle`s, because the position in a tree is always enough to uniquely
|
|
41
|
+
* identify a DOM node (we never have nodes in some bank outside of the
|
|
42
|
+
* document). The same would be true for `ReactNative`, but we must maintain a
|
|
43
|
+
* mapping that we can send efficiently serializable
|
|
44
|
+
* strings across native boundaries.
|
|
45
|
+
*
|
|
46
|
+
* Opaque name TodaysWebReact FutureWebWorkerReact ReactNative
|
|
47
|
+
* ----------------------------------------------------------------------------
|
|
48
|
+
* nodeHandle N/A rootNodeID tag
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
function findNodeHandle(componentOrHandle) {
|
|
52
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
53
|
+
var owner = ReactCurrentOwner.current;
|
|
54
|
+
if (owner !== null) {
|
|
55
|
+
process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing findNodeHandle inside its render(). ' + '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') : void 0;
|
|
56
|
+
owner._warnedAboutRefsInRender = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (componentOrHandle == null) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (typeof componentOrHandle === 'number') {
|
|
63
|
+
// Already a node handle
|
|
64
|
+
return componentOrHandle;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var component = componentOrHandle;
|
|
68
|
+
|
|
69
|
+
// TODO (balpert): Wrap iOS native components in a composite wrapper, then
|
|
70
|
+
// ReactInstanceMap.get here will always succeed for mounted components
|
|
71
|
+
var internalInstance = ReactInstanceMap.get(component);
|
|
72
|
+
if (internalInstance) {
|
|
73
|
+
return internalInstance.getNativeNode();
|
|
74
|
+
} else {
|
|
75
|
+
var rootNodeID = component._rootNodeID;
|
|
76
|
+
if (rootNodeID) {
|
|
77
|
+
return rootNodeID;
|
|
78
|
+
} else {
|
|
79
|
+
!(
|
|
80
|
+
// Native
|
|
81
|
+
typeof component === 'object' && '_rootNodeID' in component ||
|
|
82
|
+
// Composite
|
|
83
|
+
component.render != null && typeof component.render === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Argument is not a component ' + '(type: %s, keys: %s)', typeof component, Object.keys(component)) : invariant(false) : void 0;
|
|
84
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Unable to find node handle for unmounted ' + 'component.') : invariant(false) : void 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = findNodeHandle;
|
package/lib/flattenChildren.js
CHANGED
|
@@ -24,7 +24,7 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
|
|
|
24
24
|
var result = traverseContext;
|
|
25
25
|
var keyUnique = result[name] === undefined;
|
|
26
26
|
if (process.env.NODE_ENV !== 'production') {
|
|
27
|
-
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) :
|
|
27
|
+
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : void 0;
|
|
28
28
|
}
|
|
29
29
|
if (keyUnique && child != null) {
|
|
30
30
|
result[name] = child;
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
14
16
|
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
15
17
|
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
16
18
|
var ReactNativeComponent = require('./ReactNativeComponent');
|
|
17
19
|
|
|
18
|
-
var assign = require('./Object.assign');
|
|
19
20
|
var invariant = require('fbjs/lib/invariant');
|
|
20
21
|
var warning = require('fbjs/lib/warning');
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@ var warning = require('fbjs/lib/warning');
|
|
|
23
24
|
var ReactCompositeComponentWrapper = function (element) {
|
|
24
25
|
this.construct(element);
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
+
_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
|
|
27
28
|
_instantiateReactComponent: instantiateReactComponent
|
|
28
29
|
});
|
|
29
30
|
|
|
@@ -62,7 +63,7 @@ function instantiateReactComponent(node) {
|
|
|
62
63
|
instance = ReactEmptyComponent.create(instantiateReactComponent);
|
|
63
64
|
} else if (typeof node === 'object') {
|
|
64
65
|
var element = node;
|
|
65
|
-
!(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) :
|
|
66
|
+
!(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : void 0;
|
|
66
67
|
|
|
67
68
|
// Special case string values
|
|
68
69
|
if (typeof element.type === 'string') {
|
|
@@ -78,11 +79,11 @@ function instantiateReactComponent(node) {
|
|
|
78
79
|
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
79
80
|
instance = ReactNativeComponent.createInstanceForText(node);
|
|
80
81
|
} else {
|
|
81
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) :
|
|
82
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : void 0;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
if (process.env.NODE_ENV !== 'production') {
|
|
85
|
-
process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getNativeNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') :
|
|
86
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getNativeNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
// These two fields are used by the DOM and ART diffing algorithms
|
package/lib/onlyChild.js
CHANGED
|
@@ -26,7 +26,7 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
26
26
|
* structure.
|
|
27
27
|
*/
|
|
28
28
|
function onlyChild(children) {
|
|
29
|
-
!ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) :
|
|
29
|
+
!ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : void 0;
|
|
30
30
|
return children;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
+
var _assign = require('object-assign');
|
|
16
|
+
|
|
15
17
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
16
18
|
var ReactTestUtils = require('./ReactTestUtils');
|
|
17
19
|
|
|
18
|
-
var assign = require('./Object.assign');
|
|
19
20
|
var invariant = require('fbjs/lib/invariant');
|
|
20
21
|
|
|
21
22
|
function reactComponentExpect(instance) {
|
|
@@ -30,7 +31,7 @@ function reactComponentExpect(instance) {
|
|
|
30
31
|
expect(instance).not.toBeNull();
|
|
31
32
|
expect(instance).not.toBeUndefined();
|
|
32
33
|
|
|
33
|
-
!ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : invariant(false) :
|
|
34
|
+
!ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : invariant(false) : void 0;
|
|
34
35
|
var internalInstance = ReactInstanceMap.get(instance);
|
|
35
36
|
|
|
36
37
|
expect(typeof internalInstance).toBe('object');
|
|
@@ -44,7 +45,7 @@ function reactComponentExpectInternal(internalInstance) {
|
|
|
44
45
|
this._instance = internalInstance;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
_assign(reactComponentExpectInternal.prototype, {
|
|
48
49
|
// Getters -------------------------------------------------------------------
|
|
49
50
|
|
|
50
51
|
/**
|
package/lib/setInnerHTML.js
CHANGED
|
@@ -127,7 +127,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
127
127
|
}
|
|
128
128
|
} else {
|
|
129
129
|
if (process.env.NODE_ENV !== 'production') {
|
|
130
|
-
process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') :
|
|
130
|
+
process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : void 0;
|
|
131
131
|
didWarnAboutMaps = true;
|
|
132
132
|
}
|
|
133
133
|
// Iterator will provide entry [k,v] tuples rather than values.
|
|
@@ -155,7 +155,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
var childrenString = String(children);
|
|
158
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) :
|
|
158
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) : void 0;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|