* Given a DOM node, return the closest ReactDOMComponent or * ReactDOMTextComponent instance ancestor.
(node)
| 1673 | * ReactDOMTextComponent instance ancestor. |
| 1674 | */ |
| 1675 | function getClosestInstanceFromNode(node) { |
| 1676 | if (node[internalInstanceKey]) { |
| 1677 | return node[internalInstanceKey]; |
| 1678 | } |
| 1679 | |
| 1680 | while (!node[internalInstanceKey]) { |
| 1681 | if (node.parentNode) { |
| 1682 | node = node.parentNode; |
| 1683 | } else { |
| 1684 | // Top of the tree. This node must not be part of a React tree (or is |
| 1685 | // unmounted, potentially). |
| 1686 | return null; |
| 1687 | } |
| 1688 | } |
| 1689 | |
| 1690 | var inst = node[internalInstanceKey]; |
| 1691 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 1692 | // In Fiber, this will always be the deepest root. |
| 1693 | return inst; |
| 1694 | } |
| 1695 | |
| 1696 | return null; |
| 1697 | } |
| 1698 | |
| 1699 | /** |
| 1700 | * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent |
no outgoing calls
no test coverage detected