(current)
| 11976 | } |
| 11977 | |
| 11978 | function unmountHostComponents(current) { |
| 11979 | // We only have the top Fiber that was inserted but we need recurse down its |
| 11980 | var node = current; |
| 11981 | |
| 11982 | // Each iteration, currentParent is populated with node's host parent if not |
| 11983 | // currentParentIsValid. |
| 11984 | var currentParentIsValid = false; |
| 11985 | var currentParent = void 0; |
| 11986 | var currentParentIsContainer = void 0; |
| 11987 | |
| 11988 | while (true) { |
| 11989 | if (!currentParentIsValid) { |
| 11990 | var parent = node['return']; |
| 11991 | findParent: while (true) { |
| 11992 | !(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; |
| 11993 | switch (parent.tag) { |
| 11994 | case HostComponent: |
| 11995 | currentParent = parent.stateNode; |
| 11996 | currentParentIsContainer = false; |
| 11997 | break findParent; |
| 11998 | case HostRoot: |
| 11999 | currentParent = parent.stateNode.containerInfo; |
| 12000 | currentParentIsContainer = true; |
| 12001 | break findParent; |
| 12002 | case HostPortal: |
| 12003 | currentParent = parent.stateNode.containerInfo; |
| 12004 | currentParentIsContainer = true; |
| 12005 | break findParent; |
| 12006 | } |
| 12007 | parent = parent['return']; |
| 12008 | } |
| 12009 | currentParentIsValid = true; |
| 12010 | } |
| 12011 | |
| 12012 | if (node.tag === HostComponent || node.tag === HostText) { |
| 12013 | commitNestedUnmounts(node); |
| 12014 | // After all the children have unmounted, it is now safe to remove the |
| 12015 | // node from the tree. |
| 12016 | if (currentParentIsContainer) { |
| 12017 | removeChildFromContainer(currentParent, node.stateNode); |
| 12018 | } else { |
| 12019 | removeChild(currentParent, node.stateNode); |
| 12020 | } |
| 12021 | // Don't visit children because we already visited them. |
| 12022 | } else if (node.tag === HostPortal) { |
| 12023 | // When we go into a portal, it becomes the parent to remove from. |
| 12024 | // We will reassign it back when we pop the portal on the way up. |
| 12025 | currentParent = node.stateNode.containerInfo; |
| 12026 | // Visit children because portals might contain host components. |
| 12027 | if (node.child !== null) { |
| 12028 | node.child['return'] = node; |
| 12029 | node = node.child; |
| 12030 | continue; |
| 12031 | } |
| 12032 | } else { |
| 12033 | commitUnmount(node); |
| 12034 | // Visit children because we may find more host components below. |
| 12035 | if (node.child !== null) { |
no test coverage detected