* @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)
| 18279 | * @return {!number} The number of children in this subtree. |
| 18280 | */ |
| 18281 | function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { |
| 18282 | var type = typeof children; |
| 18283 | |
| 18284 | if (type === 'undefined' || type === 'boolean') { |
| 18285 | // All of the above are perceived as null. |
| 18286 | children = null; |
| 18287 | } |
| 18288 | |
| 18289 | var invokeCallback = false; |
| 18290 | |
| 18291 | if (children === null) { |
| 18292 | invokeCallback = true; |
| 18293 | } else { |
| 18294 | switch (type) { |
| 18295 | case 'string': |
| 18296 | case 'number': |
| 18297 | invokeCallback = true; |
| 18298 | break; |
| 18299 | case 'object': |
| 18300 | switch (children.$$typeof) { |
| 18301 | case REACT_ELEMENT_TYPE: |
| 18302 | case REACT_PORTAL_TYPE: |
| 18303 | invokeCallback = true; |
| 18304 | } |
| 18305 | } |
| 18306 | } |
| 18307 | |
| 18308 | if (invokeCallback) { |
| 18309 | callback(traverseContext, children, |
| 18310 | // If it's the only child, treat the name as if it was wrapped in an array |
| 18311 | // so that it's consistent if the number of children grows. |
| 18312 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); |
| 18313 | return 1; |
| 18314 | } |
| 18315 | |
| 18316 | var child = void 0; |
| 18317 | var nextName = void 0; |
| 18318 | var subtreeCount = 0; // Count of children found in the current subtree. |
| 18319 | var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; |
| 18320 | |
| 18321 | if (Array.isArray(children)) { |
| 18322 | for (var i = 0; i < children.length; i++) { |
| 18323 | child = children[i]; |
| 18324 | nextName = nextNamePrefix + getComponentKey(child, i); |
| 18325 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); |
| 18326 | } |
| 18327 | } else { |
| 18328 | var iteratorFn = getIteratorFn(children); |
| 18329 | if (typeof iteratorFn === 'function') { |
| 18330 | { |
| 18331 | // Warn about using Maps as children |
| 18332 | if (iteratorFn === children.entries) { |
| 18333 | warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum()); |
| 18334 | didWarnAboutMaps = true; |
| 18335 | } |
| 18336 | } |
| 18337 | |
| 18338 | var iterator = iteratorFn.call(children); |
no test coverage detected