* Given a DOM node, return the closest ReactDOMComponent or * ReactDOMTextComponent instance ancestor.
(node)
| 1801 | * ReactDOMTextComponent instance ancestor. |
| 1802 | */ |
| 1803 | function getClosestInstanceFromNode(node) { |
| 1804 | if (node[internalInstanceKey]) { |
| 1805 | return node[internalInstanceKey]; |
| 1806 | } |
| 1807 | |
| 1808 | while (!node[internalInstanceKey]) { |
| 1809 | if (node.parentNode) { |
| 1810 | node = node.parentNode; |
| 1811 | } else { |
| 1812 | // Top of the tree. This node must not be part of a React tree (or is |
| 1813 | // unmounted, potentially). |
| 1814 | return null; |
| 1815 | } |
| 1816 | } |
| 1817 | |
| 1818 | var inst = node[internalInstanceKey]; |
| 1819 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 1820 | // In Fiber, this will always be the deepest root. |
| 1821 | return inst; |
| 1822 | } |
| 1823 | |
| 1824 | return null; |
| 1825 | } |
| 1826 | |
| 1827 | /** |
| 1828 | * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent |
no outgoing calls
no test coverage detected