(current)
| 11760 | } |
| 11761 | |
| 11762 | function unmountHostComponents(current) { |
| 11763 | // We only have the top Fiber that was inserted but we need recurse down its |
| 11764 | var node = current; |
| 11765 | |
| 11766 | // Each iteration, currentParent is populated with node's host parent if not |
| 11767 | // currentParentIsValid. |
| 11768 | var currentParentIsValid = false; |
| 11769 | var currentParent = void 0; |
| 11770 | var currentParentIsContainer = void 0; |
| 11771 | |
| 11772 | while (true) { |
| 11773 | if (!currentParentIsValid) { |
| 11774 | var parent = node['return']; |
| 11775 | findParent: while (true) { |
| 11776 | !(parent !== null) ? invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.') : void 0; |
| 11777 | switch (parent.tag) { |
| 11778 | case HostComponent: |
| 11779 | currentParent = parent.stateNode; |
| 11780 | currentParentIsContainer = false; |
| 11781 | break findParent; |
| 11782 | case HostRoot: |
| 11783 | currentParent = parent.stateNode.containerInfo; |
| 11784 | currentParentIsContainer = true; |
| 11785 | break findParent; |
| 11786 | case HostPortal: |
| 11787 | currentParent = parent.stateNode.containerInfo; |
| 11788 | currentParentIsContainer = true; |
| 11789 | break findParent; |
| 11790 | } |
| 11791 | parent = parent['return']; |
| 11792 | } |
| 11793 | currentParentIsValid = true; |
| 11794 | } |
| 11795 | |
| 11796 | if (node.tag === HostComponent || node.tag === HostText) { |
| 11797 | commitNestedUnmounts(node); |
| 11798 | // After all the children have unmounted, it is now safe to remove the |
| 11799 | // node from the tree. |
| 11800 | if (currentParentIsContainer) { |
| 11801 | removeChildFromContainer(currentParent, node.stateNode); |
| 11802 | } else { |
| 11803 | removeChild(currentParent, node.stateNode); |
| 11804 | } |
| 11805 | // Don't visit children because we already visited them. |
| 11806 | } else if (node.tag === HostPortal) { |
| 11807 | // When we go into a portal, it becomes the parent to remove from. |
| 11808 | // We will reassign it back when we pop the portal on the way up. |
| 11809 | currentParent = node.stateNode.containerInfo; |
| 11810 | // Visit children because portals might contain host components. |
| 11811 | if (node.child !== null) { |
| 11812 | node.child['return'] = node; |
| 11813 | node = node.child; |
| 11814 | continue; |
| 11815 | } |
| 11816 | } else { |
| 11817 | commitUnmount(node); |
| 11818 | // Visit children because we may find more host components below. |
| 11819 | if (node.child !== null) { |
no test coverage detected