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

Function destroyViewTree

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

Source from the content-addressed store, hash-verified

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