* @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)
| 19184 | * @return {!number} The number of children in this subtree. |
| 19185 | */ |
| 19186 | function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { |
| 19187 | var type = typeof children; |
| 19188 | |
| 19189 | if (type === 'undefined' || type === 'boolean') { |
| 19190 | // All of the above are perceived as null. |
| 19191 | children = null; |
| 19192 | } |
| 19193 | |
| 19194 | var invokeCallback = false; |
| 19195 | |
| 19196 | if (children === null) { |
| 19197 | invokeCallback = true; |
| 19198 | } else { |
| 19199 | switch (type) { |
| 19200 | case 'string': |
| 19201 | case 'number': |
| 19202 | invokeCallback = true; |
| 19203 | break; |
| 19204 | case 'object': |
| 19205 | switch (children.$$typeof) { |
| 19206 | case REACT_ELEMENT_TYPE: |
| 19207 | case REACT_PORTAL_TYPE: |
| 19208 | invokeCallback = true; |
| 19209 | } |
| 19210 | } |
| 19211 | } |
| 19212 | |
| 19213 | if (invokeCallback) { |
| 19214 | callback(traverseContext, children, |
| 19215 | // If it's the only child, treat the name as if it was wrapped in an array |
| 19216 | // so that it's consistent if the number of children grows. |
| 19217 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); |
| 19218 | return 1; |
| 19219 | } |
| 19220 | |
| 19221 | var child = void 0; |
| 19222 | var nextName = void 0; |
| 19223 | var subtreeCount = 0; // Count of children found in the current subtree. |
| 19224 | var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; |
| 19225 | |
| 19226 | if (Array.isArray(children)) { |
| 19227 | for (var i = 0; i < children.length; i++) { |
| 19228 | child = children[i]; |
| 19229 | nextName = nextNamePrefix + getComponentKey(child, i); |
| 19230 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); |
| 19231 | } |
| 19232 | } else { |
| 19233 | var iteratorFn = getIteratorFn(children); |
| 19234 | if (typeof iteratorFn === 'function') { |
| 19235 | { |
| 19236 | // Warn about using Maps as children |
| 19237 | if (iteratorFn === children.entries) { |
| 19238 | 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()); |
| 19239 | didWarnAboutMaps = true; |
| 19240 | } |
| 19241 | } |
| 19242 | |
| 19243 | var iterator = iteratorFn.call(children); |
no test coverage detected