MCPcopy Index your code
hub / github.com/angular/angular / removeStaleDehydratedBranch

Function removeStaleDehydratedBranch

packages/core/src/hydration/views.ts:147–178  ·  view source on GitHub ↗

* In the case that we have control flow that changes branches between server and * client, we're left with dehydrated content that will not be used. We need to find * it and clean it up at the right time so that we don't see duplicate content for * a few moments before the application reaches sta

(hostLView: LView, tNode: TNode)

Source from the content-addressed store, hash-verified

145 * dehydrated content for the branch that is now stale from the server and removes it.
146 */
147function removeStaleDehydratedBranch(hostLView: LView, tNode: TNode): void {
148 let currentTNode: TNode | null = tNode;
149 while (currentTNode) {
150 // We can return here if we've found the dehydrated view and cleaned it up.
151 // Otherwise we continue on until we either find it or reach the start of
152 // the control flow.
153 if (cleanupMatchingDehydratedViews(hostLView, currentTNode)) return;
154
155 if ((currentTNode.flags & TNodeFlags.isControlFlowStart) === TNodeFlags.isControlFlowStart) {
156 // we've hit the top of the control flow loop
157 break;
158 }
159
160 currentTNode = currentTNode.prev;
161 }
162
163 currentTNode = tNode.next; // jump to place we started so we can navigate down from there
164
165 while (currentTNode) {
166 if ((currentTNode.flags & TNodeFlags.isInControlFlow) !== TNodeFlags.isInControlFlow) {
167 // we've exited control flow and need to exit the loop.
168 break;
169 }
170
171 // Similar to above, we can return here if we've found the dehydrated view
172 // and cleaned it up. Otherwise we continue on until we either find it or
173 // reach the end of the control flow.
174 if (cleanupMatchingDehydratedViews(hostLView, currentTNode)) return;
175
176 currentTNode = currentTNode.next;
177 }
178}
179
180function hasMatchingDehydratedView(lContainer: LContainer, template: string | null): boolean {
181 const views = lContainer[DEHYDRATED_VIEWS];

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…