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

Function destroyViewTree

packages/core/src/render3/node_manipulation.ts:251–288  ·  view source on GitHub ↗
(rootView: LView)

Source from the content-addressed store, hash-verified

249 * @param rootView The view to destroy
250 */
251export function destroyViewTree(rootView: LView): void {
252 // If the view has no children, we can clean it up and return early.
253 let lViewOrLContainer = rootView[CHILD_HEAD];
254 if (!lViewOrLContainer) {
255 return cleanUpView(rootView[TVIEW], rootView);
256 }
257
258 while (lViewOrLContainer) {
259 let next: LView | LContainer | null = null;
260
261 if (isLView(lViewOrLContainer)) {
262 // If LView, traverse down to child.
263 next = lViewOrLContainer[CHILD_HEAD];
264 } else {
265 ngDevMode && assertLContainer(lViewOrLContainer);
266 // If container, traverse down to its first LView.
267 const firstView: LView | undefined = lViewOrLContainer[CONTAINER_HEADER_OFFSET];
268 if (firstView) next = firstView;
269 }
270
271 if (!next) {
272 // Only clean up view when moving to the side or up, as destroy hooks
273 // should be called in order from the bottom up.
274 while (lViewOrLContainer && !lViewOrLContainer![NEXT] && lViewOrLContainer !== rootView) {
275 if (isLView(lViewOrLContainer)) {
276 cleanUpView(lViewOrLContainer[TVIEW], lViewOrLContainer);
277 }
278 lViewOrLContainer = lViewOrLContainer[PARENT];
279 }
280 if (lViewOrLContainer === null) lViewOrLContainer = rootView;
281 if (isLView(lViewOrLContainer)) {
282 cleanUpView(lViewOrLContainer[TVIEW], lViewOrLContainer);
283 }
284 next = lViewOrLContainer && lViewOrLContainer![NEXT];
285 }
286 lViewOrLContainer = next;
287 }
288}
289
290export function detachMovedView(declarationContainer: LContainer, lView: LView) {
291 ngDevMode && assertLContainer(declarationContainer);

Callers 1

destroyLViewFunction · 0.85

Calls 3

isLViewFunction · 0.90
assertLContainerFunction · 0.90
cleanUpViewFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…