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.
Files changed (184) hide show
  1. package/dist/JSXTransformer.js +986 -511
  2. package/dist/react-with-addons.js +6076 -4560
  3. package/dist/react-with-addons.min.js +6 -7
  4. package/dist/react.js +5386 -4170
  5. package/dist/react.min.js +6 -7
  6. package/lib/AutoFocusMixin.js +2 -2
  7. package/lib/BeforeInputEventPlugin.js +388 -115
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +2 -2
  10. package/lib/CSSPropertyOperations.js +58 -11
  11. package/lib/CallbackQueue.js +3 -3
  12. package/lib/ChangeEventPlugin.js +4 -4
  13. package/lib/ClientReactRootIndex.js +2 -2
  14. package/lib/DOMChildrenOperations.js +10 -47
  15. package/lib/DOMProperty.js +2 -2
  16. package/lib/DOMPropertyOperations.js +11 -16
  17. package/lib/Danger.js +8 -7
  18. package/lib/DefaultEventPluginOrder.js +3 -4
  19. package/lib/EnterLeaveEventPlugin.js +2 -2
  20. package/lib/EventConstants.js +2 -2
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +10 -8
  23. package/lib/EventPluginRegistry.js +2 -2
  24. package/lib/EventPluginUtils.js +4 -4
  25. package/lib/EventPropagators.js +2 -2
  26. package/lib/ExecutionEnvironment.js +3 -4
  27. package/lib/FallbackCompositionState.js +89 -0
  28. package/lib/HTMLDOMPropertyConfig.js +23 -10
  29. package/lib/LinkedStateMixin.js +2 -2
  30. package/lib/LinkedValueUtils.js +4 -4
  31. package/lib/LocalEventTrapMixin.js +10 -3
  32. package/lib/MobileSafariClickEventPlugin.js +2 -2
  33. package/lib/Object.assign.js +4 -2
  34. package/lib/PooledClass.js +2 -2
  35. package/lib/React.js +19 -58
  36. package/lib/ReactBrowserComponentMixin.js +4 -14
  37. package/lib/ReactBrowserEventEmitter.js +6 -8
  38. package/lib/ReactCSSTransitionGroup.js +5 -2
  39. package/lib/ReactCSSTransitionGroupChild.js +20 -7
  40. package/lib/ReactChildReconciler.js +125 -0
  41. package/lib/ReactChildren.js +13 -10
  42. package/lib/ReactClass.js +918 -0
  43. package/lib/ReactComponent.js +98 -406
  44. package/lib/ReactComponentBrowserEnvironment.js +11 -84
  45. package/lib/ReactComponentEnvironment.js +57 -0
  46. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  47. package/lib/ReactCompositeComponent.js +574 -1140
  48. package/lib/ReactContext.js +17 -3
  49. package/lib/ReactCurrentOwner.js +2 -2
  50. package/lib/ReactDOM.js +4 -9
  51. package/lib/ReactDOMButton.js +6 -7
  52. package/lib/ReactDOMComponent.js +123 -105
  53. package/lib/ReactDOMForm.js +6 -7
  54. package/lib/ReactDOMIDOperations.js +59 -77
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +5 -7
  57. package/lib/ReactDOMInput.js +6 -7
  58. package/lib/ReactDOMOption.js +6 -7
  59. package/lib/ReactDOMSelect.js +58 -66
  60. package/lib/ReactDOMSelection.js +7 -3
  61. package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
  62. package/lib/ReactDOMTextarea.js +6 -7
  63. package/lib/ReactDefaultBatchingStrategy.js +5 -5
  64. package/lib/ReactDefaultInjection.js +39 -9
  65. package/lib/ReactDefaultPerf.js +17 -8
  66. package/lib/ReactDefaultPerfAnalysis.js +2 -2
  67. package/lib/ReactElement.js +23 -15
  68. package/lib/ReactElementValidator.js +206 -89
  69. package/lib/ReactEmptyComponent.js +33 -15
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +2 -2
  72. package/lib/ReactEventListener.js +4 -5
  73. package/lib/ReactFragment.js +172 -0
  74. package/lib/ReactInjection.js +8 -6
  75. package/lib/ReactInputSelection.js +4 -5
  76. package/lib/ReactInstanceHandles.js +4 -3
  77. package/lib/ReactInstanceMap.js +47 -0
  78. package/lib/ReactLifeCycle.js +35 -0
  79. package/lib/ReactLink.js +2 -2
  80. package/lib/ReactMarkupChecksum.js +2 -2
  81. package/lib/ReactMount.js +264 -71
  82. package/lib/ReactMultiChild.js +50 -48
  83. package/lib/ReactMultiChildUpdateTypes.js +2 -2
  84. package/lib/ReactNativeComponent.js +59 -25
  85. package/lib/ReactOwner.js +5 -49
  86. package/lib/ReactPerf.js +22 -2
  87. package/lib/ReactPropTransferer.js +3 -58
  88. package/lib/ReactPropTypeLocationNames.js +2 -2
  89. package/lib/ReactPropTypeLocations.js +2 -2
  90. package/lib/ReactPropTypes.js +17 -25
  91. package/lib/ReactPutListenerQueue.js +2 -2
  92. package/lib/ReactReconcileTransaction.js +2 -2
  93. package/lib/ReactReconciler.js +121 -0
  94. package/lib/ReactRef.js +69 -0
  95. package/lib/ReactRootIndex.js +2 -2
  96. package/lib/ReactServerRendering.js +6 -4
  97. package/lib/ReactServerRenderingTransaction.js +2 -2
  98. package/lib/ReactStateSetters.js +2 -2
  99. package/lib/ReactTestUtils.js +113 -27
  100. package/lib/ReactTransitionChildMapping.js +8 -4
  101. package/lib/ReactTransitionEvents.js +2 -2
  102. package/lib/ReactTransitionGroup.js +53 -12
  103. package/lib/ReactUpdateQueue.js +295 -0
  104. package/lib/ReactUpdates.js +54 -62
  105. package/lib/ReactWithAddons.js +4 -2
  106. package/lib/SVGDOMPropertyConfig.js +2 -2
  107. package/lib/SelectEventPlugin.js +4 -4
  108. package/lib/ServerReactRootIndex.js +2 -2
  109. package/lib/SimpleEventPlugin.js +4 -4
  110. package/lib/SyntheticClipboardEvent.js +2 -3
  111. package/lib/SyntheticCompositionEvent.js +2 -3
  112. package/lib/SyntheticDragEvent.js +2 -2
  113. package/lib/SyntheticEvent.js +12 -4
  114. package/lib/SyntheticFocusEvent.js +2 -2
  115. package/lib/SyntheticInputEvent.js +2 -3
  116. package/lib/SyntheticKeyboardEvent.js +2 -2
  117. package/lib/SyntheticMouseEvent.js +3 -5
  118. package/lib/SyntheticTouchEvent.js +2 -2
  119. package/lib/SyntheticUIEvent.js +2 -2
  120. package/lib/SyntheticWheelEvent.js +2 -2
  121. package/lib/Transaction.js +4 -4
  122. package/lib/ViewportMetrics.js +3 -6
  123. package/lib/accumulateInto.js +2 -2
  124. package/lib/adler32.js +2 -2
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +4 -4
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +4 -4
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +1 -1
  133. package/lib/dangerousStyleValue.js +2 -2
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
  137. package/lib/findDOMNode.js +51 -0
  138. package/lib/flattenChildren.js +12 -23
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +2 -2
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +2 -2
  143. package/lib/getEventKey.js +2 -2
  144. package/lib/getEventModifierState.js +2 -2
  145. package/lib/getEventTarget.js +2 -2
  146. package/lib/getIteratorFn.js +42 -0
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +3 -3
  149. package/lib/getReactRootElementInContainer.js +2 -2
  150. package/lib/getTextContentAccessor.js +2 -2
  151. package/lib/getUnboundedScrollPosition.js +1 -1
  152. package/lib/hyphenate.js +1 -1
  153. package/lib/hyphenateStyleName.js +1 -1
  154. package/lib/instantiateReactComponent.js +90 -68
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +2 -2
  157. package/lib/isNode.js +4 -5
  158. package/lib/isTextInputElement.js +3 -4
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +2 -2
  161. package/lib/keyMirror.js +2 -2
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +5 -6
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/performance.js +1 -1
  167. package/lib/performanceNow.js +1 -1
  168. package/lib/quoteAttributeValueForBrowser.js +26 -0
  169. package/lib/setInnerHTML.js +13 -2
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +2 -2
  172. package/lib/shouldUpdateReactComponent.js +71 -7
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +114 -56
  175. package/lib/update.js +2 -2
  176. package/lib/warning.js +20 -2
  177. package/package.json +1 -1
  178. package/lib/CompositionEventPlugin.js +0 -257
  179. package/lib/ReactLegacyElement.js +0 -243
  180. package/lib/copyProperties.js +0 -54
  181. package/lib/deprecated.js +0 -47
  182. package/lib/merge.js +0 -34
  183. package/lib/mergeInto.js +0 -24
  184. package/lib/monitorCodeUse.js +0 -30
package/lib/onlyChild.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
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
- "use strict";
11
+ 'use strict';
12
12
 
13
13
  var ReactElement = require("./ReactElement");
14
14
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
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
@@ -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;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
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
- "use strict";
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;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
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
- "use strict";
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-2014, Facebook, Inc.
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
- "use strict";
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
- prevElement.type === nextElement.type &&
29
- prevElement.key === nextElement.key &&
30
- prevElement._owner === nextElement._owner) {
31
- return true;
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 createArrayFrom.
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-2014, Facebook, Inc.
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
- "use strict";
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
- * 1. `mapChildren` transforms strings and numbers into `ReactTextComponent`.
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
- var traverseAllChildrenImpl =
92
- function(children, nameSoFar, indexSoFar, callback, traverseContext) {
93
- var nextName, nextIndex;
94
- var subtreeCount = 0; // Count of children found in the current subtree.
95
- if (Array.isArray(children)) {
96
- for (var i = 0; i < children.length; i++) {
97
- var child = children[i];
98
- nextName = (
99
- nameSoFar +
100
- (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
101
- getComponentKey(child, i)
102
- );
103
- nextIndex = indexSoFar + subtreeCount;
104
- subtreeCount += traverseAllChildrenImpl(
105
- child,
106
- nextName,
107
- nextIndex,
108
- callback,
109
- traverseContext
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
- var storageName =
118
- isOnlyChild ? SEPARATOR + getComponentKey(children, 0) : nameSoFar;
119
- if (children == null || type === 'boolean') {
120
- // All of the above are perceived as null.
121
- callback(traverseContext, null, storageName, indexSoFar);
122
- subtreeCount = 1;
123
- } else if (type === 'string' || type === 'number' ||
124
- ReactElement.isValidElement(children)) {
125
- callback(traverseContext, children, storageName, indexSoFar);
126
- subtreeCount = 1;
127
- } else if (type === 'object') {
128
- ("production" !== process.env.NODE_ENV ? invariant(
129
- !children || children.nodeType !== 1,
130
- 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
131
- 'elements are not valid children of React components.'
132
- ) : invariant(!children || children.nodeType !== 1));
133
- for (var key in children) {
134
- if (children.hasOwnProperty(key)) {
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 + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
137
- wrapUserProvidedKey(key) + SUBSEPARATOR +
138
- getComponentKey(children[key], 0)
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
- children[key],
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
- return subtreeCount;
153
- };
208
+ }
209
+
210
+ return subtreeCount;
211
+ }
154
212
 
155
213
  /**
156
214
  * Traverses children that are typically specified as `props.children`, but