* Find the deepest React component completely containing the root of the * passed-in instance (for use when entire React trees are nested within each * other). If React trees are not nested, returns null.
(inst)
| 5829 | * other). If React trees are not nested, returns null. |
| 5830 | */ |
| 5831 | function findRootContainerNode(inst) { |
| 5832 | // TODO: It may be a good idea to cache this to prevent unnecessary DOM |
| 5833 | // traversal, but caching is difficult to do correctly without using a |
| 5834 | // mutation observer to listen for all DOM changes. |
| 5835 | while (inst['return']) { |
| 5836 | inst = inst['return']; |
| 5837 | } |
| 5838 | if (inst.tag !== HostRoot) { |
| 5839 | // This can happen if we're in a detached tree. |
| 5840 | return null; |
| 5841 | } |
| 5842 | return inst.stateNode.containerInfo; |
| 5843 | } |
| 5844 | |
| 5845 | // Used to store ancestor hierarchy in top level callback |
| 5846 | function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) { |