(current)
| 10958 | } |
| 10959 | |
| 10960 | function unmountHostComponents(current) { |
| 10961 | // We only have the top Fiber that was inserted but we need recurse down its |
| 10962 | var node = current; |
| 10963 | |
| 10964 | // Each iteration, currentParent is populated with node's host parent if not |
| 10965 | // currentParentIsValid. |
| 10966 | var currentParentIsValid = false; |
| 10967 | var currentParent = void 0; |
| 10968 | var currentParentIsContainer = void 0; |
| 10969 | |
| 10970 | while (true) { |
| 10971 | if (!currentParentIsValid) { |
| 10972 | var parent = node['return']; |
| 10973 | findParent: while (true) { |
| 10974 | !(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; |
| 10975 | switch (parent.tag) { |
| 10976 | case HostComponent: |
| 10977 | currentParent = parent.stateNode; |
| 10978 | currentParentIsContainer = false; |
| 10979 | break findParent; |
| 10980 | case HostRoot: |
| 10981 | currentParent = parent.stateNode.containerInfo; |
| 10982 | currentParentIsContainer = true; |
| 10983 | break findParent; |
| 10984 | case HostPortal: |
| 10985 | currentParent = parent.stateNode.containerInfo; |
| 10986 | currentParentIsContainer = true; |
| 10987 | break findParent; |
| 10988 | } |
| 10989 | parent = parent['return']; |
| 10990 | } |
| 10991 | currentParentIsValid = true; |
| 10992 | } |
| 10993 | |
| 10994 | if (node.tag === HostComponent || node.tag === HostText) { |
| 10995 | commitNestedUnmounts(node); |
| 10996 | // After all the children have unmounted, it is now safe to remove the |
| 10997 | // node from the tree. |
| 10998 | if (currentParentIsContainer) { |
| 10999 | removeChildFromContainer(currentParent, node.stateNode); |
| 11000 | } else { |
| 11001 | removeChild(currentParent, node.stateNode); |
| 11002 | } |
| 11003 | // Don't visit children because we already visited them. |
| 11004 | } else if (node.tag === HostPortal) { |
| 11005 | // When we go into a portal, it becomes the parent to remove from. |
| 11006 | // We will reassign it back when we pop the portal on the way up. |
| 11007 | currentParent = node.stateNode.containerInfo; |
| 11008 | // Visit children because portals might contain host components. |
| 11009 | if (node.child !== null) { |
| 11010 | node.child['return'] = node; |
| 11011 | node = node.child; |
| 11012 | continue; |
| 11013 | } |
| 11014 | } else { |
| 11015 | commitUnmount(node); |
| 11016 | // Visit children because we may find more host components below. |
| 11017 | if (node.child !== null) { |
no test coverage detected