(root, returnFiber, deletedFiber)
| 23973 | var hostParentIsContainer = false; |
| 23974 | |
| 23975 | function commitDeletionEffects(root, returnFiber, deletedFiber) { |
| 23976 | { |
| 23977 | // We only have the top Fiber that was deleted but we need to recurse down its |
| 23978 | // children to find all the terminal nodes. |
| 23979 | // Recursively delete all host nodes from the parent, detach refs, clean |
| 23980 | // up mounted layout effects, and call componentWillUnmount. |
| 23981 | // We only need to remove the topmost host child in each branch. But then we |
| 23982 | // still need to keep traversing to unmount effects, refs, and cWU. TODO: We |
| 23983 | // could split this into two separate traversals functions, where the second |
| 23984 | // one doesn't include any removeChild logic. This is maybe the same |
| 23985 | // function as "disappearLayoutEffects" (or whatever that turns into after |
| 23986 | // the layout phase is refactored to use recursion). |
| 23987 | // Before starting, find the nearest host parent on the stack so we know |
| 23988 | // which instance/container to remove the children from. |
| 23989 | // TODO: Instead of searching up the fiber return path on every deletion, we |
| 23990 | // can track the nearest host component on the JS stack as we traverse the |
| 23991 | // tree during the commit phase. This would make insertions faster, too. |
| 23992 | var parent = returnFiber; |
| 23993 | |
| 23994 | findParent: while (parent !== null) { |
| 23995 | switch (parent.tag) { |
| 23996 | case HostComponent: |
| 23997 | { |
| 23998 | hostParent = parent.stateNode; |
| 23999 | hostParentIsContainer = false; |
| 24000 | break findParent; |
| 24001 | } |
| 24002 | |
| 24003 | case HostRoot: |
| 24004 | { |
| 24005 | hostParent = parent.stateNode.containerInfo; |
| 24006 | hostParentIsContainer = true; |
| 24007 | break findParent; |
| 24008 | } |
| 24009 | |
| 24010 | case HostPortal: |
| 24011 | { |
| 24012 | hostParent = parent.stateNode.containerInfo; |
| 24013 | hostParentIsContainer = true; |
| 24014 | break findParent; |
| 24015 | } |
| 24016 | } |
| 24017 | |
| 24018 | parent = parent.return; |
| 24019 | } |
| 24020 | |
| 24021 | if (hostParent === null) { |
| 24022 | throw new Error('Expected to find a host parent. This error is likely caused by ' + 'a bug in React. Please file an issue.'); |
| 24023 | } |
| 24024 | |
| 24025 | commitDeletionEffectsOnFiber(root, returnFiber, deletedFiber); |
| 24026 | hostParent = null; |
| 24027 | hostParentIsContainer = false; |
| 24028 | } |
| 24029 | |
| 24030 | detachFiberMutation(deletedFiber); |
| 24031 | } |
| 24032 |
no test coverage detected
searching dependent graphs…