* @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)
| 19081 | * @return {!number} The number of children in this subtree. |
| 19082 | */ |
| 19083 | function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { |
| 19084 | var type = typeof children; |
| 19085 | |
| 19086 | if (type === 'undefined' || type === 'boolean') { |
| 19087 | // All of the above are perceived as null. |
| 19088 | children = null; |
| 19089 | } |
| 19090 | |
| 19091 | var invokeCallback = false; |
| 19092 | |
| 19093 | if (children === null) { |
| 19094 | invokeCallback = true; |
| 19095 | } else { |
| 19096 | switch (type) { |
| 19097 | case 'string': |
| 19098 | case 'number': |
| 19099 | invokeCallback = true; |
| 19100 | break; |
| 19101 | case 'object': |
| 19102 | switch (children.$$typeof) { |
| 19103 | case REACT_ELEMENT_TYPE: |
| 19104 | case REACT_PORTAL_TYPE: |
| 19105 | invokeCallback = true; |
| 19106 | } |
| 19107 | } |
| 19108 | } |
| 19109 | |
| 19110 | if (invokeCallback) { |
| 19111 | callback(traverseContext, children, |
| 19112 | // If it's the only child, treat the name as if it was wrapped in an array |
| 19113 | // so that it's consistent if the number of children grows. |
| 19114 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); |
| 19115 | return 1; |
| 19116 | } |
| 19117 | |
| 19118 | var child = void 0; |
| 19119 | var nextName = void 0; |
| 19120 | var subtreeCount = 0; // Count of children found in the current subtree. |
| 19121 | var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; |
| 19122 | |
| 19123 | if (Array.isArray(children)) { |
| 19124 | for (var i = 0; i < children.length; i++) { |
| 19125 | child = children[i]; |
| 19126 | nextName = nextNamePrefix + getComponentKey(child, i); |
| 19127 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); |
| 19128 | } |
| 19129 | } else { |
| 19130 | var iteratorFn = getIteratorFn(children); |
| 19131 | if (typeof iteratorFn === 'function') { |
| 19132 | { |
| 19133 | // Warn about using Maps as children |
| 19134 | if (iteratorFn === children.entries) { |
| 19135 | 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()); |
| 19136 | didWarnAboutMaps = true; |
| 19137 | } |
| 19138 | } |
| 19139 | |
| 19140 | var iterator = iteratorFn.call(children); |
no test coverage detected