* Populate `_hostNode` on each child of `inst`, assuming that the children * match up with the DOM (element) children of `node`. * * We cache entire levels at once to avoid an n^2 problem where we access the * children of a node sequentially and have to walk from the start to our target * node
(inst,node)
| 5627 | * `prepareToManageChildren` before we change `_renderedChildren`, at which |
| 5628 | * time the container's child nodes are always cached (until it unmounts). |
| 5629 | */function precacheChildNodes(inst,node){if(inst._flags&Flags.hasCachedChildNodes){return;}var children=inst._renderedChildren;var childNode=node.firstChild;outer:for(var name in children){if(!children.hasOwnProperty(name)){continue;}var childInst=children[name];var childID=getRenderedHostOrTextFromComponent(childInst)._domID;if(childID===0){// We're currently unmounting this child in ReactMultiChild; skip it. |
| 5630 | continue;}// We assume the child nodes are in the same order as the child instances. |
| 5631 | for(;childNode!==null;childNode=childNode.nextSibling){if(shouldPrecacheNode(childNode,childID)){precacheNode(childInst,childNode);continue outer;}}// We reached the end of the DOM children without finding an ID match. |
| 5632 | invariant(false,'Unable to find element with ID %s.',childID);}inst._flags|=Flags.hasCachedChildNodes;}/** |
| 5633 | * Given a DOM node, return the closest ReactDOMComponent or |
| 5634 | * ReactDOMTextComponent instance ancestor. |
| 5635 | */function getClosestInstanceFromNode(node){if(node[internalInstanceKey]){return node[internalInstanceKey];}// Walk up the tree until we find an ancestor whose instance we have cached. |
no test coverage detected