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

Function destroyViewTree

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

Source from the content-addressed store, hash-verified

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