* @param {?*} children Children tree container. * @param {!string} nameSoFar Name of the key path so far. * @param {!function} callback Callback to invoke with each child found. * @param {?*} traverseContext Used to pass information throughout the traversal * process. * @return {!number} The nu
(children, nameSoFar, callback, traverseContext)
| 17052 | * @return {!number} The number of children in this subtree. |
| 17053 | */ |
| 17054 | function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { |
| 17055 | var type = typeof children; |
| 17056 | |
| 17057 | if (type === 'undefined' || type === 'boolean') { |
| 17058 | // All of the above are perceived as null. |
| 17059 | children = null; |
| 17060 | } |
| 17061 | |
| 17062 | if (children === null || type === 'string' || type === 'number' || ReactElement.isValidElement(children)) { |
| 17063 | callback(traverseContext, children, |
| 17064 | // If it's the only child, treat the name as if it was wrapped in an array |
| 17065 | // so that it's consistent if the number of children grows. |
| 17066 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); |
| 17067 | return 1; |
| 17068 | } |
| 17069 | |
| 17070 | var child; |
| 17071 | var nextName; |
| 17072 | var subtreeCount = 0; // Count of children found in the current subtree. |
| 17073 | var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; |
| 17074 | |
| 17075 | if (Array.isArray(children)) { |
| 17076 | for (var i = 0; i < children.length; i++) { |
| 17077 | child = children[i]; |
| 17078 | nextName = nextNamePrefix + getComponentKey(child, i); |
| 17079 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); |
| 17080 | } |
| 17081 | } else { |
| 17082 | var iteratorFn = getIteratorFn(children); |
| 17083 | if (iteratorFn) { |
| 17084 | var iterator = iteratorFn.call(children); |
| 17085 | var step; |
| 17086 | if (iteratorFn !== children.entries) { |
| 17087 | var ii = 0; |
| 17088 | while (!(step = iterator.next()).done) { |
| 17089 | child = step.value; |
| 17090 | nextName = nextNamePrefix + getComponentKey(child, ii++); |
| 17091 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); |
| 17092 | } |
| 17093 | } else { |
| 17094 | if ("development" !== 'production') { |
| 17095 | "development" !== '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.') : undefined; |
| 17096 | didWarnAboutMaps = true; |
| 17097 | } |
| 17098 | // Iterator will provide entry [k,v] tuples rather than values. |
| 17099 | while (!(step = iterator.next()).done) { |
| 17100 | var entry = step.value; |
| 17101 | if (entry) { |
| 17102 | child = entry[1]; |
| 17103 | nextName = nextNamePrefix + wrapUserProvidedKey(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0); |
| 17104 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); |
| 17105 | } |
| 17106 | } |
| 17107 | } |
| 17108 | } else if (type === 'object') { |
| 17109 | var addendum = ''; |
| 17110 | if ("development" !== 'production') { |
| 17111 | addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.'; |
no test coverage detected