* 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)
| 5027 | * other). If React trees are not nested, returns null. |
| 5028 | */ |
| 5029 | function findRootContainerNode(inst) { |
| 5030 | // TODO: It may be a good idea to cache this to prevent unnecessary DOM |
| 5031 | // traversal, but caching is difficult to do correctly without using a |
| 5032 | // mutation observer to listen for all DOM changes. |
| 5033 | while (inst['return']) { |
| 5034 | inst = inst['return']; |
| 5035 | } |
| 5036 | if (inst.tag !== HostRoot) { |
| 5037 | // This can happen if we're in a detached tree. |
| 5038 | return null; |
| 5039 | } |
| 5040 | return inst.stateNode.containerInfo; |
| 5041 | } |
| 5042 | |
| 5043 | // Used to store ancestor hierarchy in top level callback |
| 5044 | function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) { |