| 18486 | } |
| 18487 | |
| 18488 | function remountFiber(current, oldWorkInProgress, newWorkInProgress) { |
| 18489 | { |
| 18490 | var returnFiber = oldWorkInProgress.return; |
| 18491 | |
| 18492 | if (returnFiber === null) { |
| 18493 | throw new Error('Cannot swap the root fiber.'); |
| 18494 | } // Disconnect from the old current. |
| 18495 | // It will get deleted. |
| 18496 | |
| 18497 | |
| 18498 | current.alternate = null; |
| 18499 | oldWorkInProgress.alternate = null; // Connect to the new tree. |
| 18500 | |
| 18501 | newWorkInProgress.index = oldWorkInProgress.index; |
| 18502 | newWorkInProgress.sibling = oldWorkInProgress.sibling; |
| 18503 | newWorkInProgress.return = oldWorkInProgress.return; |
| 18504 | newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it. |
| 18505 | |
| 18506 | if (oldWorkInProgress === returnFiber.child) { |
| 18507 | returnFiber.child = newWorkInProgress; |
| 18508 | } else { |
| 18509 | var prevSibling = returnFiber.child; |
| 18510 | |
| 18511 | if (prevSibling === null) { |
| 18512 | throw new Error('Expected parent to have a child.'); |
| 18513 | } |
| 18514 | |
| 18515 | while (prevSibling.sibling !== oldWorkInProgress) { |
| 18516 | prevSibling = prevSibling.sibling; |
| 18517 | |
| 18518 | if (prevSibling === null) { |
| 18519 | throw new Error('Expected to find the previous sibling.'); |
| 18520 | } |
| 18521 | } |
| 18522 | |
| 18523 | prevSibling.sibling = newWorkInProgress; |
| 18524 | } // Delete the old fiber and place the new one. |
| 18525 | // Since the old fiber is disconnected, we have to schedule it manually. |
| 18526 | |
| 18527 | |
| 18528 | var last = returnFiber.lastEffect; |
| 18529 | |
| 18530 | if (last !== null) { |
| 18531 | last.nextEffect = current; |
| 18532 | returnFiber.lastEffect = current; |
| 18533 | } else { |
| 18534 | returnFiber.firstEffect = returnFiber.lastEffect = current; |
| 18535 | } |
| 18536 | |
| 18537 | current.nextEffect = null; |
| 18538 | current.effectTag = Deletion; |
| 18539 | newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber. |
| 18540 | |
| 18541 | return newWorkInProgress; |
| 18542 | } |
| 18543 | } |
| 18544 | |
| 18545 | function beginWork(current, workInProgress, renderExpirationTime) { |