react 0.13.3 → 0.14.0-alpha1
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 +7 -0
- package/addons/CSSTransitionGroup.js +1 -0
- package/addons/LinkedStateMixin.js +1 -0
- package/addons/Perf.js +1 -0
- package/addons/PureRenderMixin.js +1 -0
- package/addons/TestUtils.js +1 -0
- package/addons/TransitionGroup.js +1 -0
- package/addons/batchedUpdates.js +1 -0
- package/addons/cloneWithProps.js +1 -0
- package/addons/createFragment.js +1 -0
- package/addons/renderSubtreeIntoContainer.js +1 -0
- package/addons/shallowCompare.js +1 -0
- package/addons/update.js +1 -0
- package/dist/JSXTransformer.js +3355 -1685
- package/dist/react-with-addons.js +3092 -5145
- package/dist/react-with-addons.min.js +6 -8
- package/dist/react.js +2772 -4594
- package/dist/react.min.js +5 -6
- package/lib/AutoFocusMixin.js +4 -3
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +4 -3
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +24 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +41 -65
- package/lib/DOMPropertyOperations.js +30 -51
- package/lib/Danger.js +19 -60
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +27 -38
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +5 -17
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +34 -64
- package/lib/LocalEventTrapMixin.js +9 -16
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +8 -11
- package/lib/React.js +20 -38
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +18 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +7 -16
- package/lib/ReactClass.js +78 -231
- package/lib/ReactComponent.js +17 -51
- package/lib/ReactComponentBrowserEnvironment.js +4 -6
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +4 -5
- package/lib/ReactCompositeComponent.js +83 -318
- package/lib/ReactContext.js +2 -44
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +3 -2
- package/lib/ReactDOMButton.js +3 -4
- package/lib/ReactDOMComponent.js +182 -148
- package/lib/ReactDOMForm.js +3 -3
- package/lib/ReactDOMIDOperations.js +11 -20
- package/lib/ReactDOMIframe.js +3 -3
- package/lib/ReactDOMImg.js +3 -3
- package/lib/ReactDOMInput.js +22 -35
- package/lib/ReactDOMOption.js +52 -10
- package/lib/ReactDOMSelect.js +50 -28
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +15 -27
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +21 -40
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +35 -72
- package/lib/ReactElementValidator.js +51 -110
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +2 -2
- package/lib/ReactEventEmitterMixin.js +3 -12
- package/lib/ReactEventListener.js +16 -38
- package/lib/ReactFragment.js +23 -54
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +11 -21
- package/lib/ReactInstanceHandles.js +27 -57
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +136 -260
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +7 -11
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +13 -46
- package/lib/ReactReconcileTransaction.js +9 -34
- package/lib/ReactReconciler.js +9 -19
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +7 -15
- package/lib/ReactServerRenderingTransaction.js +7 -32
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +89 -165
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +27 -90
- package/lib/ReactUpdates.js +27 -79
- package/lib/ReactWithAddons.js +7 -6
- package/lib/SVGDOMPropertyConfig.js +39 -2
- package/lib/SelectEventPlugin.js +28 -29
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +136 -128
- package/lib/SyntheticClipboardEvent.js +3 -7
- package/lib/SyntheticCompositionEvent.js +3 -9
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +8 -10
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +3 -9
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +8 -14
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +3 -3
- package/lib/SyntheticWheelEvent.js +11 -15
- package/lib/Transaction.js +12 -24
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -2
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +5 -11
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createFullPageComponent.js +4 -11
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +5 -24
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +5 -5
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +14 -38
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +2 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +19 -82
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +264 -0
- package/lib/warning.js +17 -15
- package/package.json +3 -3
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
|
@@ -0,0 +1,16 @@
|
|
|
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 renderSubtreeIntoContainer
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactMount = require("./ReactMount");
|
|
15
|
+
|
|
16
|
+
module.exports = ReactMount.renderSubtreeIntoContainer;
|
package/lib/setInnerHTML.js
CHANGED
|
@@ -26,14 +26,14 @@ var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
|
|
|
26
26
|
* @param {string} html
|
|
27
27
|
* @internal
|
|
28
28
|
*/
|
|
29
|
-
var setInnerHTML = function(node, html) {
|
|
29
|
+
var setInnerHTML = function (node, html) {
|
|
30
30
|
node.innerHTML = html;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// Win8 apps: Allow all html to be inserted
|
|
34
34
|
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
|
|
35
|
-
setInnerHTML = function(node, html) {
|
|
36
|
-
MSApp.execUnsafeLocalFunction(function() {
|
|
35
|
+
setInnerHTML = function (node, html) {
|
|
36
|
+
MSApp.execUnsafeLocalFunction(function () {
|
|
37
37
|
node.innerHTML = html;
|
|
38
38
|
});
|
|
39
39
|
};
|
|
@@ -49,7 +49,7 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
49
49
|
var testElement = document.createElement('div');
|
|
50
50
|
testElement.innerHTML = ' ';
|
|
51
51
|
if (testElement.innerHTML === '') {
|
|
52
|
-
setInnerHTML = function(node, html) {
|
|
52
|
+
setInnerHTML = function (node, html) {
|
|
53
53
|
// Magic theory: IE8 supposedly differentiates between added and updated
|
|
54
54
|
// nodes when processing innerHTML, innerHTML on updated nodes suffers
|
|
55
55
|
// from worse whitespace behavior. Re-adding a node like this triggers
|
|
@@ -63,11 +63,14 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
63
63
|
// thin air on IE8, this only happens if there is no visible text
|
|
64
64
|
// in-front of the non-visible tags. Piggyback on the whitespace fix
|
|
65
65
|
// and simply check if any non-visible tags appear in the source.
|
|
66
|
-
if (WHITESPACE_TEST.test(html) ||
|
|
67
|
-
html[0] === '<' && NONVISIBLE_TEST.test(html)) {
|
|
66
|
+
if (WHITESPACE_TEST.test(html) || html[0] === '<' && NONVISIBLE_TEST.test(html)) {
|
|
68
67
|
// Recover leading whitespace by temporarily prepending any character.
|
|
69
68
|
// \uFEFF has the potential advantage of being zero-width/invisible.
|
|
70
|
-
|
|
69
|
+
// UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode
|
|
70
|
+
// in hopes that this is preserved even if "\uFEFF" is transformed to
|
|
71
|
+
// the actual Unicode character (by Babel, for example).
|
|
72
|
+
// https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216
|
|
73
|
+
node.innerHTML = String.fromCharCode(65279) + html;
|
|
71
74
|
|
|
72
75
|
// deleteData leaves an empty `TextNode` which offsets the index of all
|
|
73
76
|
// children. Definitely want to avoid this.
|
|
@@ -84,4 +87,4 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
module.exports = setInnerHTML;
|
|
90
|
+
module.exports = setInnerHTML;
|
package/lib/setTextContent.js
CHANGED
|
@@ -25,16 +25,16 @@ var setInnerHTML = require("./setInnerHTML");
|
|
|
25
25
|
* @param {string} text
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
|
-
var setTextContent = function(node, text) {
|
|
28
|
+
var setTextContent = function (node, text) {
|
|
29
29
|
node.textContent = text;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
if (ExecutionEnvironment.canUseDOM) {
|
|
33
33
|
if (!('textContent' in document.documentElement)) {
|
|
34
|
-
setTextContent = function(node, text) {
|
|
34
|
+
setTextContent = function (node, text) {
|
|
35
35
|
setInnerHTML(node, escapeTextContentForBrowser(text));
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
module.exports = setTextContent;
|
|
40
|
+
module.exports = setTextContent;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 shallowCompare
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var shallowEqual = require("./shallowEqual");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Does a shallow comparison for props and state.
|
|
18
|
+
* See ReactComponentWithPureRenderMixin
|
|
19
|
+
*/
|
|
20
|
+
function shallowCompare(instance, nextProps, nextState) {
|
|
21
|
+
return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = shallowCompare;
|
package/lib/shallowEqual.js
CHANGED
|
@@ -22,21 +22,27 @@ function shallowEqual(objA, objB) {
|
|
|
22
22
|
if (objA === objB) {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
|
|
26
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var keysA = Object.keys(objA);
|
|
31
|
+
var keysB = Object.keys(objB);
|
|
32
|
+
|
|
33
|
+
if (keysA.length !== keysB.length) {
|
|
34
|
+
return false;
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
for
|
|
35
|
-
|
|
36
|
+
|
|
37
|
+
// Test for A's keys different from B.
|
|
38
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
39
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
40
|
+
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
|
|
36
41
|
return false;
|
|
37
42
|
}
|
|
38
43
|
}
|
|
44
|
+
|
|
39
45
|
return true;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
module.exports = shallowEqual;
|
|
48
|
+
module.exports = shallowEqual;
|
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var warning = require("./warning");
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* Given a `prevElement` and `nextElement`, determines if the existing
|
|
19
17
|
* instance should be updated as opposed to being destroyed or replaced by a new
|
|
@@ -30,71 +28,12 @@ function shouldUpdateReactComponent(prevElement, nextElement) {
|
|
|
30
28
|
var prevType = typeof prevElement;
|
|
31
29
|
var nextType = typeof nextElement;
|
|
32
30
|
if (prevType === 'string' || prevType === 'number') {
|
|
33
|
-
return
|
|
31
|
+
return nextType === 'string' || nextType === 'number';
|
|
34
32
|
} else {
|
|
35
|
-
|
|
36
|
-
prevElement.type === nextElement.type &&
|
|
37
|
-
prevElement.key === nextElement.key) {
|
|
38
|
-
var ownersMatch = prevElement._owner === nextElement._owner;
|
|
39
|
-
var prevName = null;
|
|
40
|
-
var nextName = null;
|
|
41
|
-
var nextDisplayName = null;
|
|
42
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
43
|
-
if (!ownersMatch) {
|
|
44
|
-
if (prevElement._owner != null &&
|
|
45
|
-
prevElement._owner.getPublicInstance() != null &&
|
|
46
|
-
prevElement._owner.getPublicInstance().constructor != null) {
|
|
47
|
-
prevName =
|
|
48
|
-
prevElement._owner.getPublicInstance().constructor.displayName;
|
|
49
|
-
}
|
|
50
|
-
if (nextElement._owner != null &&
|
|
51
|
-
nextElement._owner.getPublicInstance() != null &&
|
|
52
|
-
nextElement._owner.getPublicInstance().constructor != null) {
|
|
53
|
-
nextName =
|
|
54
|
-
nextElement._owner.getPublicInstance().constructor.displayName;
|
|
55
|
-
}
|
|
56
|
-
if (nextElement.type != null &&
|
|
57
|
-
nextElement.type.displayName != null) {
|
|
58
|
-
nextDisplayName = nextElement.type.displayName;
|
|
59
|
-
}
|
|
60
|
-
if (nextElement.type != null && typeof nextElement.type === 'string') {
|
|
61
|
-
nextDisplayName = nextElement.type;
|
|
62
|
-
}
|
|
63
|
-
if (typeof nextElement.type !== 'string' ||
|
|
64
|
-
nextElement.type === 'input' ||
|
|
65
|
-
nextElement.type === 'textarea') {
|
|
66
|
-
if ((prevElement._owner != null &&
|
|
67
|
-
prevElement._owner._isOwnerNecessary === false) ||
|
|
68
|
-
(nextElement._owner != null &&
|
|
69
|
-
nextElement._owner._isOwnerNecessary === false)) {
|
|
70
|
-
if (prevElement._owner != null) {
|
|
71
|
-
prevElement._owner._isOwnerNecessary = true;
|
|
72
|
-
}
|
|
73
|
-
if (nextElement._owner != null) {
|
|
74
|
-
nextElement._owner._isOwnerNecessary = true;
|
|
75
|
-
}
|
|
76
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
77
|
-
false,
|
|
78
|
-
'<%s /> is being rendered by both %s and %s using the same ' +
|
|
79
|
-
'key (%s) in the same place. Currently, this means that ' +
|
|
80
|
-
'they don\'t preserve state. This behavior should be very ' +
|
|
81
|
-
'rare so we\'re considering deprecating it. Please contact ' +
|
|
82
|
-
'the React team and explain your use case so that we can ' +
|
|
83
|
-
'take that into consideration.',
|
|
84
|
-
nextDisplayName || 'Unknown Component',
|
|
85
|
-
prevName || '[Unknown]',
|
|
86
|
-
nextName || '[Unknown]',
|
|
87
|
-
prevElement.key
|
|
88
|
-
) : null);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return ownersMatch;
|
|
94
|
-
}
|
|
33
|
+
return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
|
|
95
34
|
}
|
|
96
35
|
}
|
|
97
36
|
return false;
|
|
98
37
|
}
|
|
99
38
|
|
|
100
|
-
module.exports = shouldUpdateReactComponent;
|
|
39
|
+
module.exports = shouldUpdateReactComponent;
|
package/lib/toArray.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* @typechecks
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
13
15
|
var invariant = require("./invariant");
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -26,24 +28,11 @@ function toArray(obj) {
|
|
|
26
28
|
|
|
27
29
|
// Some browse builtin objects can report typeof 'function' (e.g. NodeList in
|
|
28
30
|
// old versions of Safari).
|
|
29
|
-
|
|
30
|
-
!Array.isArray(obj) &&
|
|
31
|
-
(typeof obj === 'object' || typeof obj === 'function'),
|
|
32
|
-
'toArray: Array-like object expected'
|
|
33
|
-
) : invariant(!Array.isArray(obj) &&
|
|
34
|
-
(typeof obj === 'object' || typeof obj === 'function')));
|
|
31
|
+
'production' !== process.env.NODE_ENV ? invariant(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function'), 'toArray: Array-like object expected') : invariant(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function'));
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
typeof length === 'number',
|
|
38
|
-
'toArray: Object needs a length property'
|
|
39
|
-
) : invariant(typeof length === 'number'));
|
|
33
|
+
'production' !== process.env.NODE_ENV ? invariant(typeof length === 'number', 'toArray: Object needs a length property') : invariant(typeof length === 'number');
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
length === 0 ||
|
|
43
|
-
(length - 1) in obj,
|
|
44
|
-
'toArray: Object should have keys for indices'
|
|
45
|
-
) : invariant(length === 0 ||
|
|
46
|
-
(length - 1) in obj));
|
|
35
|
+
'production' !== process.env.NODE_ENV ? invariant(length === 0 || length - 1 in obj, 'toArray: Object should have keys for indices') : invariant(length === 0 || length - 1 in obj);
|
|
47
36
|
|
|
48
37
|
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
|
|
49
38
|
// without method will throw during the slice call and skip straight to the
|
|
@@ -51,9 +40,7 @@ function toArray(obj) {
|
|
|
51
40
|
if (obj.hasOwnProperty) {
|
|
52
41
|
try {
|
|
53
42
|
return Array.prototype.slice.call(obj);
|
|
54
|
-
} catch (e) {
|
|
55
|
-
// IE < 9 does not support Array#slice on collections objects
|
|
56
|
-
}
|
|
43
|
+
} catch (e) {}
|
|
57
44
|
}
|
|
58
45
|
|
|
59
46
|
// Fall back to copying key by key. This assumes all keys have a value,
|
|
@@ -66,3 +53,5 @@ function toArray(obj) {
|
|
|
66
53
|
}
|
|
67
54
|
|
|
68
55
|
module.exports = toArray;
|
|
56
|
+
|
|
57
|
+
// IE < 9 does not support Array#slice on collections objects
|
|
@@ -64,10 +64,7 @@ function getComponentKey(component, index) {
|
|
|
64
64
|
* @return {string} An escaped string.
|
|
65
65
|
*/
|
|
66
66
|
function escapeUserProvidedKey(text) {
|
|
67
|
-
return ('' + text).replace(
|
|
68
|
-
userProvidedKeyEscapeRegex,
|
|
69
|
-
userProvidedKeyEscaper
|
|
70
|
-
);
|
|
67
|
+
return ('' + text).replace(userProvidedKeyEscapeRegex, userProvidedKeyEscaper);
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
/**
|
|
@@ -90,13 +87,7 @@ function wrapUserProvidedKey(key) {
|
|
|
90
87
|
* process.
|
|
91
88
|
* @return {!number} The number of children in this subtree.
|
|
92
89
|
*/
|
|
93
|
-
function traverseAllChildrenImpl(
|
|
94
|
-
children,
|
|
95
|
-
nameSoFar,
|
|
96
|
-
indexSoFar,
|
|
97
|
-
callback,
|
|
98
|
-
traverseContext
|
|
99
|
-
) {
|
|
90
|
+
function traverseAllChildrenImpl(children, nameSoFar, indexSoFar, callback, traverseContext) {
|
|
100
91
|
var type = typeof children;
|
|
101
92
|
|
|
102
93
|
if (type === 'undefined' || type === 'boolean') {
|
|
@@ -104,18 +95,11 @@ function traverseAllChildrenImpl(
|
|
|
104
95
|
children = null;
|
|
105
96
|
}
|
|
106
97
|
|
|
107
|
-
if (children === null ||
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
traverseContext,
|
|
113
|
-
children,
|
|
114
|
-
// If it's the only child, treat the name as if it was wrapped in an array
|
|
115
|
-
// so that it's consistent if the number of children grows.
|
|
116
|
-
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar,
|
|
117
|
-
indexSoFar
|
|
118
|
-
);
|
|
98
|
+
if (children === null || type === 'string' || type === 'number' || ReactElement.isValidElement(children)) {
|
|
99
|
+
callback(traverseContext, children,
|
|
100
|
+
// If it's the only child, treat the name as if it was wrapped in an array
|
|
101
|
+
// so that it's consistent if the number of children grows.
|
|
102
|
+
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar, indexSoFar);
|
|
119
103
|
return 1;
|
|
120
104
|
}
|
|
121
105
|
|
|
@@ -125,18 +109,9 @@ function traverseAllChildrenImpl(
|
|
|
125
109
|
if (Array.isArray(children)) {
|
|
126
110
|
for (var i = 0; i < children.length; i++) {
|
|
127
111
|
child = children[i];
|
|
128
|
-
nextName = (
|
|
129
|
-
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
130
|
-
getComponentKey(child, i)
|
|
131
|
-
);
|
|
112
|
+
nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + getComponentKey(child, i);
|
|
132
113
|
nextIndex = indexSoFar + subtreeCount;
|
|
133
|
-
subtreeCount += traverseAllChildrenImpl(
|
|
134
|
-
child,
|
|
135
|
-
nextName,
|
|
136
|
-
nextIndex,
|
|
137
|
-
callback,
|
|
138
|
-
traverseContext
|
|
139
|
-
);
|
|
114
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
|
|
140
115
|
}
|
|
141
116
|
} else {
|
|
142
117
|
var iteratorFn = getIteratorFn(children);
|
|
@@ -147,27 +122,13 @@ function traverseAllChildrenImpl(
|
|
|
147
122
|
var ii = 0;
|
|
148
123
|
while (!(step = iterator.next()).done) {
|
|
149
124
|
child = step.value;
|
|
150
|
-
nextName = (
|
|
151
|
-
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
152
|
-
getComponentKey(child, ii++)
|
|
153
|
-
);
|
|
125
|
+
nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + getComponentKey(child, ii++);
|
|
154
126
|
nextIndex = indexSoFar + subtreeCount;
|
|
155
|
-
subtreeCount += traverseAllChildrenImpl(
|
|
156
|
-
child,
|
|
157
|
-
nextName,
|
|
158
|
-
nextIndex,
|
|
159
|
-
callback,
|
|
160
|
-
traverseContext
|
|
161
|
-
);
|
|
127
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
|
|
162
128
|
}
|
|
163
129
|
} else {
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
didWarnAboutMaps,
|
|
167
|
-
'Using Maps as children is not yet fully supported. It is an ' +
|
|
168
|
-
'experimental feature that might be removed. Convert it to a ' +
|
|
169
|
-
'sequence / iterable of keyed ReactElements instead.'
|
|
170
|
-
) : null);
|
|
130
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
131
|
+
'production' !== process.env.NODE_ENV ? 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.') : null;
|
|
171
132
|
didWarnAboutMaps = true;
|
|
172
133
|
}
|
|
173
134
|
// Iterator will provide entry [k,v] tuples rather than values.
|
|
@@ -175,45 +136,21 @@ function traverseAllChildrenImpl(
|
|
|
175
136
|
var entry = step.value;
|
|
176
137
|
if (entry) {
|
|
177
138
|
child = entry[1];
|
|
178
|
-
nextName = (
|
|
179
|
-
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
180
|
-
wrapUserProvidedKey(entry[0]) + SUBSEPARATOR +
|
|
181
|
-
getComponentKey(child, 0)
|
|
182
|
-
);
|
|
139
|
+
nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + wrapUserProvidedKey(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0);
|
|
183
140
|
nextIndex = indexSoFar + subtreeCount;
|
|
184
|
-
subtreeCount += traverseAllChildrenImpl(
|
|
185
|
-
child,
|
|
186
|
-
nextName,
|
|
187
|
-
nextIndex,
|
|
188
|
-
callback,
|
|
189
|
-
traverseContext
|
|
190
|
-
);
|
|
141
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
|
|
191
142
|
}
|
|
192
143
|
}
|
|
193
144
|
}
|
|
194
145
|
} else if (type === 'object') {
|
|
195
|
-
|
|
196
|
-
children.nodeType !== 1,
|
|
197
|
-
'traverseAllChildren(...): Encountered an invalid child; DOM ' +
|
|
198
|
-
'elements are not valid children of React components.'
|
|
199
|
-
) : invariant(children.nodeType !== 1));
|
|
146
|
+
'production' !== process.env.NODE_ENV ? invariant(children.nodeType !== 1, 'traverseAllChildren(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(children.nodeType !== 1);
|
|
200
147
|
var fragment = ReactFragment.extract(children);
|
|
201
148
|
for (var key in fragment) {
|
|
202
149
|
if (fragment.hasOwnProperty(key)) {
|
|
203
150
|
child = fragment[key];
|
|
204
|
-
nextName = (
|
|
205
|
-
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
206
|
-
wrapUserProvidedKey(key) + SUBSEPARATOR +
|
|
207
|
-
getComponentKey(child, 0)
|
|
208
|
-
);
|
|
151
|
+
nextName = (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) + wrapUserProvidedKey(key) + SUBSEPARATOR + getComponentKey(child, 0);
|
|
209
152
|
nextIndex = indexSoFar + subtreeCount;
|
|
210
|
-
subtreeCount += traverseAllChildrenImpl(
|
|
211
|
-
child,
|
|
212
|
-
nextName,
|
|
213
|
-
nextIndex,
|
|
214
|
-
callback,
|
|
215
|
-
traverseContext
|
|
216
|
-
);
|
|
153
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, nextIndex, callback, traverseContext);
|
|
217
154
|
}
|
|
218
155
|
}
|
|
219
156
|
}
|
|
@@ -246,4 +183,4 @@ function traverseAllChildren(children, callback, traverseContext) {
|
|
|
246
183
|
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
|
|
247
184
|
}
|
|
248
185
|
|
|
249
|
-
module.exports = traverseAllChildren;
|
|
186
|
+
module.exports = traverseAllChildren;
|