(current)
| 11863 | } |
| 11864 | |
| 11865 | function unmountHostComponents(current) { |
| 11866 | // We only have the top Fiber that was inserted but we need recurse down its |
| 11867 | var node = current; |
| 11868 | |
| 11869 | // Each iteration, currentParent is populated with node's host parent if not |
| 11870 | // currentParentIsValid. |
| 11871 | var currentParentIsValid = false; |
| 11872 | var currentParent = void 0; |
| 11873 | var currentParentIsContainer = void 0; |
| 11874 | |
| 11875 | while (true) { |
| 11876 | if (!currentParentIsValid) { |
| 11877 | var parent = node['return']; |
| 11878 | findParent: while (true) { |
| 11879 | !(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; |
| 11880 | switch (parent.tag) { |
| 11881 | case HostComponent: |
| 11882 | currentParent = parent.stateNode; |
| 11883 | currentParentIsContainer = false; |
| 11884 | break findParent; |
| 11885 | case HostRoot: |
| 11886 | currentParent = parent.stateNode.containerInfo; |
| 11887 | currentParentIsContainer = true; |
| 11888 | break findParent; |
| 11889 | case HostPortal: |
| 11890 | currentParent = parent.stateNode.containerInfo; |
| 11891 | currentParentIsContainer = true; |
| 11892 | break findParent; |
| 11893 | } |
| 11894 | parent = parent['return']; |
| 11895 | } |
| 11896 | currentParentIsValid = true; |
| 11897 | } |
| 11898 | |
| 11899 | if (node.tag === HostComponent || node.tag === HostText) { |
| 11900 | commitNestedUnmounts(node); |
| 11901 | // After all the children have unmounted, it is now safe to remove the |
| 11902 | // node from the tree. |
| 11903 | if (currentParentIsContainer) { |
| 11904 | removeChildFromContainer(currentParent, node.stateNode); |
| 11905 | } else { |
| 11906 | removeChild(currentParent, node.stateNode); |
| 11907 | } |
| 11908 | // Don't visit children because we already visited them. |
| 11909 | } else if (node.tag === HostPortal) { |
| 11910 | // When we go into a portal, it becomes the parent to remove from. |
| 11911 | // We will reassign it back when we pop the portal on the way up. |
| 11912 | currentParent = node.stateNode.containerInfo; |
| 11913 | // Visit children because portals might contain host components. |
| 11914 | if (node.child !== null) { |
| 11915 | node.child['return'] = node; |
| 11916 | node = node.child; |
| 11917 | continue; |
| 11918 | } |
| 11919 | } else { |
| 11920 | commitUnmount(node); |
| 11921 | // Visit children because we may find more host components below. |
| 11922 | if (node.child !== null) { |
no test coverage detected