(current)
| 11818 | } |
| 11819 | |
| 11820 | function unmountHostComponents(current) { |
| 11821 | // We only have the top Fiber that was inserted but we need recurse down its |
| 11822 | var node = current; |
| 11823 | |
| 11824 | // Each iteration, currentParent is populated with node's host parent if not |
| 11825 | // currentParentIsValid. |
| 11826 | var currentParentIsValid = false; |
| 11827 | var currentParent = void 0; |
| 11828 | var currentParentIsContainer = void 0; |
| 11829 | |
| 11830 | while (true) { |
| 11831 | if (!currentParentIsValid) { |
| 11832 | var parent = node['return']; |
| 11833 | findParent: while (true) { |
| 11834 | !(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; |
| 11835 | switch (parent.tag) { |
| 11836 | case HostComponent: |
| 11837 | currentParent = parent.stateNode; |
| 11838 | currentParentIsContainer = false; |
| 11839 | break findParent; |
| 11840 | case HostRoot: |
| 11841 | currentParent = parent.stateNode.containerInfo; |
| 11842 | currentParentIsContainer = true; |
| 11843 | break findParent; |
| 11844 | case HostPortal: |
| 11845 | currentParent = parent.stateNode.containerInfo; |
| 11846 | currentParentIsContainer = true; |
| 11847 | break findParent; |
| 11848 | } |
| 11849 | parent = parent['return']; |
| 11850 | } |
| 11851 | currentParentIsValid = true; |
| 11852 | } |
| 11853 | |
| 11854 | if (node.tag === HostComponent || node.tag === HostText) { |
| 11855 | commitNestedUnmounts(node); |
| 11856 | // After all the children have unmounted, it is now safe to remove the |
| 11857 | // node from the tree. |
| 11858 | if (currentParentIsContainer) { |
| 11859 | removeChildFromContainer(currentParent, node.stateNode); |
| 11860 | } else { |
| 11861 | removeChild(currentParent, node.stateNode); |
| 11862 | } |
| 11863 | // Don't visit children because we already visited them. |
| 11864 | } else if (node.tag === HostPortal) { |
| 11865 | // When we go into a portal, it becomes the parent to remove from. |
| 11866 | // We will reassign it back when we pop the portal on the way up. |
| 11867 | currentParent = node.stateNode.containerInfo; |
| 11868 | // Visit children because portals might contain host components. |
| 11869 | if (node.child !== null) { |
| 11870 | node.child['return'] = node; |
| 11871 | node = node.child; |
| 11872 | continue; |
| 11873 | } |
| 11874 | } else { |
| 11875 | commitUnmount(node); |
| 11876 | // Visit children because we may find more host components below. |
| 11877 | if (node.child !== null) { |
no test coverage detected