* Ensure that every element either is passed in a static location, in an * array with an explicit keys property defined, or in an object literal * with valid key property. * * @internal * @param {ReactNode} node Statically passed child of any type. * @param {*} parentType node's parent's type.
(node, parentType)
| 18729 | * @param {*} parentType node's parent's type. |
| 18730 | */ |
| 18731 | function validateChildKeys(node, parentType) { |
| 18732 | if (typeof node !== 'object') { |
| 18733 | return; |
| 18734 | } |
| 18735 | if (Array.isArray(node)) { |
| 18736 | for (var i = 0; i < node.length; i++) { |
| 18737 | var child = node[i]; |
| 18738 | if (isValidElement(child)) { |
| 18739 | validateExplicitKey(child, parentType); |
| 18740 | } |
| 18741 | } |
| 18742 | } else if (isValidElement(node)) { |
| 18743 | // This element was passed in a valid location. |
| 18744 | if (node._store) { |
| 18745 | node._store.validated = true; |
| 18746 | } |
| 18747 | } else if (node) { |
| 18748 | var iteratorFn = getIteratorFn(node); |
| 18749 | if (typeof iteratorFn === 'function') { |
| 18750 | // Entry iterators used to provide implicit keys, |
| 18751 | // but now we print a separate warning for them later. |
| 18752 | if (iteratorFn !== node.entries) { |
| 18753 | var iterator = iteratorFn.call(node); |
| 18754 | var step = void 0; |
| 18755 | while (!(step = iterator.next()).done) { |
| 18756 | if (isValidElement(step.value)) { |
| 18757 | validateExplicitKey(step.value, parentType); |
| 18758 | } |
| 18759 | } |
| 18760 | } |
| 18761 | } |
| 18762 | } |
| 18763 | } |
| 18764 | |
| 18765 | /** |
| 18766 | * Given an element, validate that its props follow the propTypes definition, |
no test coverage detected