* 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)
| 7158 | |
| 7159 | |
| 7160 | function findRootContainerNode(inst) { |
| 7161 | if (inst.tag === HostRoot) { |
| 7162 | return inst.stateNode.containerInfo; |
| 7163 | } // TODO: It may be a good idea to cache this to prevent unnecessary DOM |
| 7164 | // traversal, but caching is difficult to do correctly without using a |
| 7165 | // mutation observer to listen for all DOM changes. |
| 7166 | |
| 7167 | |
| 7168 | while (inst.return) { |
| 7169 | inst = inst.return; |
| 7170 | } |
| 7171 | |
| 7172 | if (inst.tag !== HostRoot) { |
| 7173 | // This can happen if we're in a detached tree. |
| 7174 | return null; |
| 7175 | } |
| 7176 | |
| 7177 | return inst.stateNode.containerInfo; |
| 7178 | } |
| 7179 | /** |
| 7180 | * Allows registered plugins an opportunity to extract events from top-level |
| 7181 | * native browser events. |