react 0.12.2 → 0.13.0-beta.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/JSXTransformer.js +986 -511
- package/dist/react-with-addons.js +6076 -4560
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +5386 -4170
- package/dist/react.min.js +6 -7
- package/lib/AutoFocusMixin.js +2 -2
- package/lib/BeforeInputEventPlugin.js +388 -115
- package/lib/CSSCore.js +1 -1
- package/lib/CSSProperty.js +2 -2
- package/lib/CSSPropertyOperations.js +58 -11
- package/lib/CallbackQueue.js +3 -3
- package/lib/ChangeEventPlugin.js +4 -4
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +10 -47
- package/lib/DOMProperty.js +2 -2
- package/lib/DOMPropertyOperations.js +11 -16
- package/lib/Danger.js +8 -7
- package/lib/DefaultEventPluginOrder.js +3 -4
- package/lib/EnterLeaveEventPlugin.js +2 -2
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +1 -1
- package/lib/EventPluginHub.js +10 -8
- package/lib/EventPluginRegistry.js +2 -2
- package/lib/EventPluginUtils.js +4 -4
- package/lib/EventPropagators.js +2 -2
- package/lib/ExecutionEnvironment.js +3 -4
- package/lib/FallbackCompositionState.js +89 -0
- package/lib/HTMLDOMPropertyConfig.js +23 -10
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +4 -4
- package/lib/LocalEventTrapMixin.js +10 -3
- package/lib/MobileSafariClickEventPlugin.js +2 -2
- package/lib/Object.assign.js +4 -2
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +19 -58
- package/lib/ReactBrowserComponentMixin.js +4 -14
- package/lib/ReactBrowserEventEmitter.js +6 -8
- package/lib/ReactCSSTransitionGroup.js +5 -2
- package/lib/ReactCSSTransitionGroupChild.js +20 -7
- package/lib/ReactChildReconciler.js +125 -0
- package/lib/ReactChildren.js +13 -10
- package/lib/ReactClass.js +918 -0
- package/lib/ReactComponent.js +98 -406
- package/lib/ReactComponentBrowserEnvironment.js +11 -84
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +574 -1140
- package/lib/ReactContext.js +17 -3
- package/lib/ReactCurrentOwner.js +2 -2
- package/lib/ReactDOM.js +4 -9
- package/lib/ReactDOMButton.js +6 -7
- package/lib/ReactDOMComponent.js +123 -105
- package/lib/ReactDOMForm.js +6 -7
- package/lib/ReactDOMIDOperations.js +59 -77
- package/lib/ReactDOMIframe.js +43 -0
- package/lib/ReactDOMImg.js +5 -7
- package/lib/ReactDOMInput.js +6 -7
- package/lib/ReactDOMOption.js +6 -7
- package/lib/ReactDOMSelect.js +58 -66
- package/lib/ReactDOMSelection.js +7 -3
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
- package/lib/ReactDOMTextarea.js +6 -7
- package/lib/ReactDefaultBatchingStrategy.js +5 -5
- package/lib/ReactDefaultInjection.js +39 -9
- package/lib/ReactDefaultPerf.js +17 -8
- package/lib/ReactDefaultPerfAnalysis.js +2 -2
- package/lib/ReactElement.js +23 -15
- package/lib/ReactElementValidator.js +206 -89
- package/lib/ReactEmptyComponent.js +33 -15
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +4 -5
- package/lib/ReactFragment.js +172 -0
- package/lib/ReactInjection.js +8 -6
- package/lib/ReactInputSelection.js +4 -5
- package/lib/ReactInstanceHandles.js +4 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactLifeCycle.js +35 -0
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +2 -2
- package/lib/ReactMount.js +264 -71
- package/lib/ReactMultiChild.js +50 -48
- package/lib/ReactMultiChildUpdateTypes.js +2 -2
- package/lib/ReactNativeComponent.js +59 -25
- package/lib/ReactOwner.js +5 -49
- package/lib/ReactPerf.js +22 -2
- package/lib/ReactPropTransferer.js +3 -58
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +2 -2
- package/lib/ReactPropTypes.js +17 -25
- package/lib/ReactPutListenerQueue.js +2 -2
- package/lib/ReactReconcileTransaction.js +2 -2
- package/lib/ReactReconciler.js +121 -0
- package/lib/ReactRef.js +69 -0
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +6 -4
- package/lib/ReactServerRenderingTransaction.js +2 -2
- package/lib/ReactStateSetters.js +2 -2
- package/lib/ReactTestUtils.js +113 -27
- package/lib/ReactTransitionChildMapping.js +8 -4
- package/lib/ReactTransitionEvents.js +2 -2
- package/lib/ReactTransitionGroup.js +53 -12
- package/lib/ReactUpdateQueue.js +295 -0
- package/lib/ReactUpdates.js +54 -62
- package/lib/ReactWithAddons.js +4 -2
- package/lib/SVGDOMPropertyConfig.js +2 -2
- package/lib/SelectEventPlugin.js +4 -4
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +4 -4
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -2
- package/lib/SyntheticEvent.js +12 -4
- package/lib/SyntheticFocusEvent.js +2 -2
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -2
- package/lib/SyntheticMouseEvent.js +3 -5
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +2 -2
- package/lib/Transaction.js +4 -4
- package/lib/ViewportMetrics.js +3 -6
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +2 -2
- package/lib/camelize.js +1 -1
- package/lib/camelizeStyleName.js +1 -1
- package/lib/cloneWithProps.js +4 -4
- package/lib/containsNode.js +1 -1
- package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
- package/lib/createFullPageComponent.js +4 -4
- package/lib/createNodesFromMarkup.js +4 -4
- package/lib/cx.js +1 -1
- package/lib/dangerousStyleValue.js +2 -2
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +1 -1
- package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
- package/lib/findDOMNode.js +51 -0
- package/lib/flattenChildren.js +12 -23
- package/lib/focusNode.js +1 -1
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +1 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +2 -2
- package/lib/getEventModifierState.js +2 -2
- package/lib/getEventTarget.js +2 -2
- package/lib/getIteratorFn.js +42 -0
- package/lib/getMarkupWrap.js +1 -1
- package/lib/getNodeForCharacterOffset.js +3 -3
- package/lib/getReactRootElementInContainer.js +2 -2
- package/lib/getTextContentAccessor.js +2 -2
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +1 -1
- package/lib/hyphenateStyleName.js +1 -1
- package/lib/instantiateReactComponent.js +90 -68
- package/lib/invariant.js +1 -1
- package/lib/isEventSupported.js +2 -2
- package/lib/isNode.js +4 -5
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +2 -2
- package/lib/keyOf.js +1 -1
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +5 -6
- package/lib/onlyChild.js +2 -2
- package/lib/performance.js +1 -1
- package/lib/performanceNow.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +26 -0
- package/lib/setInnerHTML.js +13 -2
- package/lib/setTextContent.js +40 -0
- package/lib/shallowEqual.js +2 -2
- package/lib/shouldUpdateReactComponent.js +71 -7
- package/lib/toArray.js +2 -2
- package/lib/traverseAllChildren.js +114 -56
- package/lib/update.js +2 -2
- package/lib/warning.js +20 -2
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/copyProperties.js +0 -54
- package/lib/deprecated.js +0 -47
- package/lib/merge.js +0 -34
- package/lib/mergeInto.js +0 -24
- package/lib/monitorCodeUse.js +0 -30
package/lib/onlyChild.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @providesModule onlyChild
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
'use strict';
|
|
12
12
|
|
|
13
13
|
var ReactElement = require("./ReactElement");
|
|
14
14
|
|
package/lib/performance.js
CHANGED
package/lib/performanceNow.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
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 quoteAttributeValueForBrowser
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Escapes attribute value to prevent scripting attacks.
|
|
18
|
+
*
|
|
19
|
+
* @param {*} value Value to escape.
|
|
20
|
+
* @return {string} An escaped string.
|
|
21
|
+
*/
|
|
22
|
+
function quoteAttributeValueForBrowser(value) {
|
|
23
|
+
return '"' + escapeTextContentForBrowser(value) + '"';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = quoteAttributeValueForBrowser;
|
package/lib/setInnerHTML.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* @providesModule setInnerHTML
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/* globals MSApp */
|
|
13
|
+
|
|
14
|
+
'use strict';
|
|
13
15
|
|
|
14
16
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
15
17
|
|
|
@@ -28,6 +30,15 @@ var setInnerHTML = function(node, html) {
|
|
|
28
30
|
node.innerHTML = html;
|
|
29
31
|
};
|
|
30
32
|
|
|
33
|
+
// Win8 apps: Allow all html to be inserted
|
|
34
|
+
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
|
|
35
|
+
setInnerHTML = function(node, html) {
|
|
36
|
+
MSApp.execUnsafeLocalFunction(function() {
|
|
37
|
+
node.innerHTML = html;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
if (ExecutionEnvironment.canUseDOM) {
|
|
32
43
|
// IE8: When updating a just created node with innerHTML only leading
|
|
33
44
|
// whitespace is removed. When updating an existing node with innerHTML
|
|
@@ -0,0 +1,40 @@
|
|
|
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 setTextContent
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
15
|
+
var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
|
|
16
|
+
var setInnerHTML = require("./setInnerHTML");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set the textContent property of a node, ensuring that whitespace is preserved
|
|
20
|
+
* even in IE8. innerText is a poor substitute for textContent and, among many
|
|
21
|
+
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves
|
|
22
|
+
* as it should.
|
|
23
|
+
*
|
|
24
|
+
* @param {DOMElement} node
|
|
25
|
+
* @param {string} text
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
var setTextContent = function(node, text) {
|
|
29
|
+
node.textContent = text;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
33
|
+
if (!('textContent' in document.documentElement)) {
|
|
34
|
+
setTextContent = function(node, text) {
|
|
35
|
+
setInnerHTML(node, escapeTextContentForBrowser(text));
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = setTextContent;
|
package/lib/shallowEqual.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @providesModule shallowEqual
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Performs equality by iterating through keys on an object and returning
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
var warning = require("./warning");
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Given a `prevElement` and `nextElement`, determines if the existing
|
|
@@ -24,11 +26,73 @@
|
|
|
24
26
|
* @protected
|
|
25
27
|
*/
|
|
26
28
|
function shouldUpdateReactComponent(prevElement, nextElement) {
|
|
27
|
-
if (prevElement && nextElement
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (prevElement != null && nextElement != null) {
|
|
30
|
+
var prevType = typeof prevElement;
|
|
31
|
+
var nextType = typeof nextElement;
|
|
32
|
+
if (prevType === 'string' || prevType === 'number') {
|
|
33
|
+
return (nextType === 'string' || nextType === 'number');
|
|
34
|
+
} else {
|
|
35
|
+
if (nextType === 'object' &&
|
|
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
|
+
}
|
|
95
|
+
}
|
|
32
96
|
}
|
|
33
97
|
return false;
|
|
34
98
|
}
|
package/lib/toArray.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014, Facebook, Inc.
|
|
2
|
+
* Copyright 2014-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -16,7 +16,7 @@ var invariant = require("./invariant");
|
|
|
16
16
|
* Convert array-like objects to arrays.
|
|
17
17
|
*
|
|
18
18
|
* This API assumes the caller knows the contents of the data type. For less
|
|
19
|
-
* well defined inputs use
|
|
19
|
+
* well defined inputs use createArrayFromMixed.
|
|
20
20
|
*
|
|
21
21
|
* @param {object|function|filelist} obj
|
|
22
22
|
* @return {array}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,22 +9,21 @@
|
|
|
9
9
|
* @providesModule traverseAllChildren
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactElement = require("./ReactElement");
|
|
15
|
+
var ReactFragment = require("./ReactFragment");
|
|
15
16
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
16
17
|
|
|
18
|
+
var getIteratorFn = require("./getIteratorFn");
|
|
17
19
|
var invariant = require("./invariant");
|
|
18
20
|
|
|
19
21
|
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
|
|
20
22
|
var SUBSEPARATOR = ':';
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
* TODO: Test that
|
|
24
|
-
*
|
|
25
|
-
* 2. it('should fail when supplied duplicate key', function() {
|
|
26
|
-
* 3. That a single child and an array with one item have the same key pattern.
|
|
27
|
-
* });
|
|
25
|
+
* TODO: Test that a single child and an array with one item have the same key
|
|
26
|
+
* pattern.
|
|
28
27
|
*/
|
|
29
28
|
|
|
30
29
|
var userProvidedKeyEscaperLookup = {
|
|
@@ -88,58 +87,90 @@ function wrapUserProvidedKey(key) {
|
|
|
88
87
|
* process.
|
|
89
88
|
* @return {!number} The number of children in this subtree.
|
|
90
89
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} else {
|
|
113
|
-
var type = typeof children;
|
|
114
|
-
var isOnlyChild = nameSoFar === '';
|
|
90
|
+
function traverseAllChildrenImpl(
|
|
91
|
+
children,
|
|
92
|
+
nameSoFar,
|
|
93
|
+
indexSoFar,
|
|
94
|
+
callback,
|
|
95
|
+
traverseContext
|
|
96
|
+
) {
|
|
97
|
+
var type = typeof children;
|
|
98
|
+
|
|
99
|
+
if (type === 'undefined' || type === 'boolean') {
|
|
100
|
+
// All of the above are perceived as null.
|
|
101
|
+
children = null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (children === null ||
|
|
105
|
+
type === 'string' ||
|
|
106
|
+
type === 'number' ||
|
|
107
|
+
ReactElement.isValidElement(children)) {
|
|
108
|
+
callback(
|
|
109
|
+
traverseContext,
|
|
110
|
+
children,
|
|
115
111
|
// If it's the only child, treat the name as if it was wrapped in an array
|
|
116
|
-
// so that it's consistent if the number of children grows
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
// so that it's consistent if the number of children grows.
|
|
113
|
+
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar,
|
|
114
|
+
indexSoFar
|
|
115
|
+
);
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
var child, nextName, nextIndex;
|
|
120
|
+
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
121
|
+
|
|
122
|
+
if (Array.isArray(children)) {
|
|
123
|
+
for (var i = 0; i < children.length; i++) {
|
|
124
|
+
child = children[i];
|
|
125
|
+
nextName = (
|
|
126
|
+
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
127
|
+
getComponentKey(child, i)
|
|
128
|
+
);
|
|
129
|
+
nextIndex = indexSoFar + subtreeCount;
|
|
130
|
+
subtreeCount += traverseAllChildrenImpl(
|
|
131
|
+
child,
|
|
132
|
+
nextName,
|
|
133
|
+
nextIndex,
|
|
134
|
+
callback,
|
|
135
|
+
traverseContext
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
var iteratorFn = getIteratorFn(children);
|
|
140
|
+
if (iteratorFn) {
|
|
141
|
+
var iterator = iteratorFn.call(children);
|
|
142
|
+
var step;
|
|
143
|
+
if (iteratorFn !== children.entries) {
|
|
144
|
+
var ii = 0;
|
|
145
|
+
while (!(step = iterator.next()).done) {
|
|
146
|
+
child = step.value;
|
|
147
|
+
nextName = (
|
|
148
|
+
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
149
|
+
getComponentKey(child, ii++)
|
|
150
|
+
);
|
|
151
|
+
nextIndex = indexSoFar + subtreeCount;
|
|
152
|
+
subtreeCount += traverseAllChildrenImpl(
|
|
153
|
+
child,
|
|
154
|
+
nextName,
|
|
155
|
+
nextIndex,
|
|
156
|
+
callback,
|
|
157
|
+
traverseContext
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
162
|
+
while (!(step = iterator.next()).done) {
|
|
163
|
+
var entry = step.value;
|
|
164
|
+
if (entry) {
|
|
165
|
+
child = entry[1];
|
|
135
166
|
nextName = (
|
|
136
|
-
nameSoFar
|
|
137
|
-
wrapUserProvidedKey(
|
|
138
|
-
getComponentKey(
|
|
167
|
+
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
168
|
+
wrapUserProvidedKey(entry[0]) + SUBSEPARATOR +
|
|
169
|
+
getComponentKey(child, 0)
|
|
139
170
|
);
|
|
140
171
|
nextIndex = indexSoFar + subtreeCount;
|
|
141
172
|
subtreeCount += traverseAllChildrenImpl(
|
|
142
|
-
|
|
173
|
+
child,
|
|
143
174
|
nextName,
|
|
144
175
|
nextIndex,
|
|
145
176
|
callback,
|
|
@@ -148,9 +179,36 @@ var traverseAllChildrenImpl =
|
|
|
148
179
|
}
|
|
149
180
|
}
|
|
150
181
|
}
|
|
182
|
+
} else if (type === 'object') {
|
|
183
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
184
|
+
children.nodeType !== 1,
|
|
185
|
+
'traverseAllChildren(...): Encountered an invalid child; DOM ' +
|
|
186
|
+
'elements are not valid children of React components.'
|
|
187
|
+
) : invariant(children.nodeType !== 1));
|
|
188
|
+
var fragment = ReactFragment.extract(children);
|
|
189
|
+
for (var key in fragment) {
|
|
190
|
+
if (fragment.hasOwnProperty(key)) {
|
|
191
|
+
child = fragment[key];
|
|
192
|
+
nextName = (
|
|
193
|
+
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
|
|
194
|
+
wrapUserProvidedKey(key) + SUBSEPARATOR +
|
|
195
|
+
getComponentKey(child, 0)
|
|
196
|
+
);
|
|
197
|
+
nextIndex = indexSoFar + subtreeCount;
|
|
198
|
+
subtreeCount += traverseAllChildrenImpl(
|
|
199
|
+
child,
|
|
200
|
+
nextName,
|
|
201
|
+
nextIndex,
|
|
202
|
+
callback,
|
|
203
|
+
traverseContext
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
151
207
|
}
|
|
152
|
-
|
|
153
|
-
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return subtreeCount;
|
|
211
|
+
}
|
|
154
212
|
|
|
155
213
|
/**
|
|
156
214
|
* Traverses children that are typically specified as `props.children`, but
|