(finishedRoot, current, renderPriorityLevel)
| 20527 | } |
| 20528 | |
| 20529 | function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { |
| 20530 | // We only have the top Fiber that was deleted but we need to recurse down its |
| 20531 | // children to find all the terminal nodes. |
| 20532 | var node = current; // Each iteration, currentParent is populated with node's host parent if not |
| 20533 | // currentParentIsValid. |
| 20534 | |
| 20535 | var currentParentIsValid = false; // Note: these two variables *must* always be updated together. |
| 20536 | |
| 20537 | var currentParent; |
| 20538 | var currentParentIsContainer; |
| 20539 | |
| 20540 | while (true) { |
| 20541 | if (!currentParentIsValid) { |
| 20542 | var parent = node.return; |
| 20543 | |
| 20544 | findParent: while (true) { |
| 20545 | if (!(parent !== null)) { |
| 20546 | { |
| 20547 | throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); |
| 20548 | } |
| 20549 | } |
| 20550 | |
| 20551 | var parentStateNode = parent.stateNode; |
| 20552 | |
| 20553 | switch (parent.tag) { |
| 20554 | case HostComponent: |
| 20555 | currentParent = parentStateNode; |
| 20556 | currentParentIsContainer = false; |
| 20557 | break findParent; |
| 20558 | |
| 20559 | case HostRoot: |
| 20560 | currentParent = parentStateNode.containerInfo; |
| 20561 | currentParentIsContainer = true; |
| 20562 | break findParent; |
| 20563 | |
| 20564 | case HostPortal: |
| 20565 | currentParent = parentStateNode.containerInfo; |
| 20566 | currentParentIsContainer = true; |
| 20567 | break findParent; |
| 20568 | |
| 20569 | } |
| 20570 | |
| 20571 | parent = parent.return; |
| 20572 | } |
| 20573 | |
| 20574 | currentParentIsValid = true; |
| 20575 | } |
| 20576 | |
| 20577 | if (node.tag === HostComponent || node.tag === HostText) { |
| 20578 | commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the |
| 20579 | // node from the tree. |
| 20580 | |
| 20581 | if (currentParentIsContainer) { |
| 20582 | removeChildFromContainer(currentParent, node.stateNode); |
| 20583 | } else { |
| 20584 | removeChild(currentParent, node.stateNode); |
| 20585 | } // Don't visit children because we already visited them. |
| 20586 |
no test coverage detected