* Given a DOM node, return the closest ReactDOMComponent or * ReactDOMTextComponent instance ancestor.
(node)
| 2578 | * ReactDOMTextComponent instance ancestor. |
| 2579 | */ |
| 2580 | function getClosestInstanceFromNode(node) { |
| 2581 | if (node[internalInstanceKey]) { |
| 2582 | return node[internalInstanceKey]; |
| 2583 | } |
| 2584 | |
| 2585 | while (!node[internalInstanceKey]) { |
| 2586 | if (node.parentNode) { |
| 2587 | node = node.parentNode; |
| 2588 | } else { |
| 2589 | // Top of the tree. This node must not be part of a React tree (or is |
| 2590 | // unmounted, potentially). |
| 2591 | return null; |
| 2592 | } |
| 2593 | } |
| 2594 | |
| 2595 | var inst = node[internalInstanceKey]; |
| 2596 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 2597 | // In Fiber, this will always be the deepest root. |
| 2598 | return inst; |
| 2599 | } |
| 2600 | |
| 2601 | return null; |
| 2602 | } |
| 2603 | |
| 2604 | /** |
| 2605 | * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent |
no outgoing calls
no test coverage detected