(rootView: LView)
| 249 | * @param rootView The view to destroy |
| 250 | */ |
| 251 | export 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 | |
| 290 | export function detachMovedView(declarationContainer: LContainer, lView: LView) { |
| 291 | ngDevMode && assertLContainer(declarationContainer); |
no test coverage detected
searching dependent graphs…