* Given a DOM node, return the closest ReactDOMComponent or * ReactDOMTextComponent instance ancestor.
(node)
| 2691 | * ReactDOMTextComponent instance ancestor. |
| 2692 | */ |
| 2693 | function getClosestInstanceFromNode(node) { |
| 2694 | if (node[internalInstanceKey]) { |
| 2695 | return node[internalInstanceKey]; |
| 2696 | } |
| 2697 | |
| 2698 | while (!node[internalInstanceKey]) { |
| 2699 | if (node.parentNode) { |
| 2700 | node = node.parentNode; |
| 2701 | } else { |
| 2702 | // Top of the tree. This node must not be part of a React tree (or is |
| 2703 | // unmounted, potentially). |
| 2704 | return null; |
| 2705 | } |
| 2706 | } |
| 2707 | |
| 2708 | var inst = node[internalInstanceKey]; |
| 2709 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 2710 | // In Fiber, this will always be the deepest root. |
| 2711 | return inst; |
| 2712 | } |
| 2713 | |
| 2714 | return null; |
| 2715 | } |
| 2716 | |
| 2717 | /** |
| 2718 | * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent |
no outgoing calls
no test coverage detected