| 340 | } |
| 341 | |
| 342 | function recordHostChildrenToDelete( |
| 343 | childrenToDelete: FiberNode[], |
| 344 | unmountFiber: FiberNode |
| 345 | ) { |
| 346 | // 1. 找到第一个root host节点 |
| 347 | const lastOne = childrenToDelete[childrenToDelete.length - 1]; |
| 348 | |
| 349 | if (!lastOne) { |
| 350 | childrenToDelete.push(unmountFiber); |
| 351 | } else { |
| 352 | let node = lastOne.sibling; |
| 353 | while (node !== null) { |
| 354 | if (unmountFiber === node) { |
| 355 | childrenToDelete.push(unmountFiber); |
| 356 | } |
| 357 | node = node.sibling; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | // 2. 每找到一个 host节点,判断下这个节点是不是 1 找到那个节点的兄弟节点 |
| 362 | } |
| 363 | |
| 364 | function commitDeletion(childToDelete: FiberNode, root: FiberRootNode) { |
| 365 | const rootChildrenToDelete: FiberNode[] = []; |