(children, array, escapedPrefix, nameSoFar, callback)
| 1006 | } |
| 1007 | |
| 1008 | function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { |
| 1009 | var type = typeof children; |
| 1010 | |
| 1011 | if (type === 'undefined' || type === 'boolean') { |
| 1012 | // All of the above are perceived as null. |
| 1013 | children = null; |
| 1014 | } |
| 1015 | |
| 1016 | var invokeCallback = false; |
| 1017 | |
| 1018 | if (children === null) { |
| 1019 | invokeCallback = true; |
| 1020 | } else { |
| 1021 | switch (type) { |
| 1022 | case 'string': |
| 1023 | case 'number': |
| 1024 | invokeCallback = true; |
| 1025 | break; |
| 1026 | |
| 1027 | case 'object': |
| 1028 | switch (children.$$typeof) { |
| 1029 | case REACT_ELEMENT_TYPE: |
| 1030 | case REACT_PORTAL_TYPE: |
| 1031 | invokeCallback = true; |
| 1032 | } |
| 1033 | |
| 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | if (invokeCallback) { |
| 1038 | var _child = children; |
| 1039 | var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array |
| 1040 | // so that it's consistent if the number of children grows: |
| 1041 | |
| 1042 | var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; |
| 1043 | |
| 1044 | if (isArray(mappedChild)) { |
| 1045 | var escapedChildKey = ''; |
| 1046 | |
| 1047 | if (childKey != null) { |
| 1048 | escapedChildKey = escapeUserProvidedKey(childKey) + '/'; |
| 1049 | } |
| 1050 | |
| 1051 | mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) { |
| 1052 | return c; |
| 1053 | }); |
| 1054 | } else if (mappedChild != null) { |
| 1055 | if (isValidElement(mappedChild)) { |
| 1056 | { |
| 1057 | // The `if` statement here prevents auto-disabling of the safe |
| 1058 | // coercion ESLint rule, so we must manually disable it below. |
| 1059 | // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key |
| 1060 | if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) { |
| 1061 | checkKeyStringCoercion(mappedChild.key); |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as |
no test coverage detected
searching dependent graphs…