* Given a DOM node, return the closest ReactDOMComponent or * ReactDOMTextComponent instance ancestor.
(node)
| 2440 | * ReactDOMTextComponent instance ancestor. |
| 2441 | */ |
| 2442 | function getClosestInstanceFromNode(node) { |
| 2443 | if (node[internalInstanceKey]) { |
| 2444 | return node[internalInstanceKey]; |
| 2445 | } |
| 2446 | |
| 2447 | while (!node[internalInstanceKey]) { |
| 2448 | if (node.parentNode) { |
| 2449 | node = node.parentNode; |
| 2450 | } else { |
| 2451 | // Top of the tree. This node must not be part of a React tree (or is |
| 2452 | // unmounted, potentially). |
| 2453 | return null; |
| 2454 | } |
| 2455 | } |
| 2456 | |
| 2457 | var inst = node[internalInstanceKey]; |
| 2458 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 2459 | // In Fiber, this will always be the deepest root. |
| 2460 | return inst; |
| 2461 | } |
| 2462 | |
| 2463 | return null; |
| 2464 | } |
| 2465 | |
| 2466 | /** |
| 2467 | * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent |
no outgoing calls
no test coverage detected