MCPcopy Create free account
hub / github.com/angular/angular / destroyViewTree

Function destroyViewTree

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

Source from the content-addressed store, hash-verified

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