* 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)
| 3586 | |
| 3587 | |
| 3588 | function findRootContainerNode(inst) { |
| 3589 | if (inst.tag === HostRoot) { |
| 3590 | return inst.stateNode.containerInfo; |
| 3591 | } // TODO: It may be a good idea to cache this to prevent unnecessary DOM |
| 3592 | // traversal, but caching is difficult to do correctly without using a |
| 3593 | // mutation observer to listen for all DOM changes. |
| 3594 | |
| 3595 | |
| 3596 | while (inst.return) { |
| 3597 | inst = inst.return; |
| 3598 | } |
| 3599 | |
| 3600 | if (inst.tag !== HostRoot) { |
| 3601 | // This can happen if we're in a detached tree. |
| 3602 | return null; |
| 3603 | } |
| 3604 | |
| 3605 | return inst.stateNode.containerInfo; |
| 3606 | } |
| 3607 | /** |
| 3608 | * Allows registered plugins an opportunity to extract events from top-level |
| 3609 | * native browser events. |