refactor(ivy): LView is a proper linked list (#28382)

- TView no longer stores childIndex
- LView now as CHILD_HEAD and CHILD_TAIL

TView used to store the head of the list, therefor all LViews had to have the same head, which is incorrect.

PR Close #28382
This commit is contained in:
Ben Lesh
2019-01-25 15:21:51 -08:00
parent ba6aa93aa3
commit 929fe029c2
7 changed files with 27 additions and 34 deletions

View File

@ -46,7 +46,7 @@ export const CHILD_TAIL = 15;
export const CONTENT_QUERIES = 16;
export const DECLARATION_VIEW = 17;
/** Size of LView's header. Necessary to adjust for it when setting slots. */
export const HEADER_OFFSET = 18;
export const HEADER_OFFSET = 19;
// This interface replaces the real LView interface if it is an arg or a
@ -79,12 +79,13 @@ export interface LView extends Array<any> {
[FLAGS]: LViewFlags;
/**
* The parent view is needed when we exit the view and must restore the previous
* `LView`. Without this, the render method would have to keep a stack of
* This may store an {@link LView} or {@link LContainer}.
*
* `LView` - The parent view. This is needed when we exit the view and must restore the previous
* LView. Without this, the render method would have to keep a stack of
* views as it is recursively rendering templates.
*
* This is the "insertion" view for embedded views. This allows us to properly
* destroy embedded views.
* `LContainer` - The current view is part of a container, and is an embedded view.
*/
[PARENT]: LView|LContainer|null;
@ -162,6 +163,15 @@ export interface LView extends Array<any> {
/** An optional custom sanitizer. */
[SANITIZER]: Sanitizer|null;
/**
* Reference to the first LView or LContainer beneath this LView in
* the hierarchy.
*
* Necessary to store this so views can traverse through their nested views
* to remove listeners and call onDestroy callbacks.
*/
[CHILD_HEAD]: LView|LContainer|null;
/**
* The last LView or LContainer beneath this LView in the hierarchy.
*
@ -393,18 +403,6 @@ export interface TView {
*/
viewQueryStartIndex: number;
/**
* Index of the host node of the first LView or LContainer beneath this LView in
* the hierarchy.
*
* Necessary to store this so views can traverse through their nested views
* to remove listeners and call onDestroy callbacks.
*
* For embedded views, we store the index of an LContainer's host rather than the first
* LView to avoid managing splicing when views are added/removed.
*/
childIndex: number;
/**
* A reference to the first child node located in the view.
*/