( request: Request, trackedPostpones: PostponedHoles, task: Task, segment: Segment, )
| 3889 | } |
| 3890 | |
| 3891 | function trackPostpone( |
| 3892 | request: Request, |
| 3893 | trackedPostpones: PostponedHoles, |
| 3894 | task: Task, |
| 3895 | segment: Segment, |
| 3896 | ): void { |
| 3897 | segment.status = POSTPONED; |
| 3898 | |
| 3899 | const keyPath = task.keyPath; |
| 3900 | const boundary = task.blockedBoundary; |
| 3901 | |
| 3902 | if (boundary === null) { |
| 3903 | segment.id = request.nextSegmentId++; |
| 3904 | trackedPostpones.rootSlots = segment.id; |
| 3905 | if (request.completedRootSegment !== null) { |
| 3906 | // Postpone the root if this was a deeper segment. |
| 3907 | request.completedRootSegment.status = POSTPONED; |
| 3908 | } |
| 3909 | return; |
| 3910 | } |
| 3911 | |
| 3912 | if (boundary !== null && boundary.status === PENDING) { |
| 3913 | const boundaryNode = trackPostponedBoundary( |
| 3914 | request, |
| 3915 | trackedPostpones, |
| 3916 | boundary, |
| 3917 | ); |
| 3918 | if (boundary.trackedContentKeyPath === keyPath && task.childIndex === -1) { |
| 3919 | // Assign ID |
| 3920 | if (segment.id === -1) { |
| 3921 | if (segment.parentFlushed) { |
| 3922 | // If this segment's parent was already flushed, it means we really just |
| 3923 | // skipped the parent and this segment is now the root. |
| 3924 | segment.id = boundary.rootSegmentID; |
| 3925 | } else { |
| 3926 | segment.id = request.nextSegmentId++; |
| 3927 | } |
| 3928 | } |
| 3929 | // We postponed directly inside the Suspense boundary so we mark this for resuming. |
| 3930 | boundaryNode[3] = segment.id; |
| 3931 | return; |
| 3932 | } |
| 3933 | // Otherwise, fall through to add the child node. |
| 3934 | } |
| 3935 | |
| 3936 | // We know that this will leave a hole so we might as well assign an ID now. |
| 3937 | // We might have one already if we had a parent that gave us its ID. |
| 3938 | if (segment.id === -1) { |
| 3939 | if (segment.parentFlushed && boundary !== null) { |
| 3940 | // If this segment's parent was already flushed, it means we really just |
| 3941 | // skipped the parent and this segment is now the root. |
| 3942 | segment.id = boundary.rootSegmentID; |
| 3943 | } else { |
| 3944 | segment.id = request.nextSegmentId++; |
| 3945 | } |
| 3946 | } |
| 3947 | |
| 3948 | if (task.childIndex === -1) { |
no test coverage detected