refactor(ivy): LContainer now stored in LView[PARENT] (#28382)

- Removes CONTAINER_INDEX
- LView[PARENT] now contains LContainer when necessary
- Removes now unused arguments to methods after refactor

PR Close #28382
This commit is contained in:
Ben Lesh
2019-01-28 14:45:31 -08:00
parent f0f81f482e
commit ba6aa93aa3
19 changed files with 235 additions and 159 deletions

View File

@ -62,7 +62,7 @@ export interface LContainer extends Array<any> {
* Access to the parent view is necessary so we can propagate back
* up from inside a container to parent[NEXT].
*/
[PARENT]: LView|null;
[PARENT]: LView;
/**
* This allows us to jump from a container to a sibling container or component
@ -85,10 +85,10 @@ export interface LContainer extends Array<any> {
* It could also be a styling context if this is a node with a style/class
* binding.
*/
[HOST]: RElement|RComment|StylingContext|LView;
readonly[HOST]: RElement|RComment|StylingContext|LView;
/** The comment element that serves as an anchor for this LContainer. */
[NATIVE]: RComment;
readonly[NATIVE]: RComment;
}
// Note: This hack is necessary so we don't erroneously get a circular dependency

View File

@ -110,11 +110,27 @@ export const domRendererFactory3: RendererFactory3 = {
/** Subset of API needed for appending elements and text nodes. */
export interface RNode {
/**
* Returns the parent Element, Document, or DocumentFragment
*/
parentNode: RNode|null;
/**
* Returns the parent Element if there is one
*/
parentElement: RElement|null;
/**
* Gets the Node immediately following this one in the parent's childNodes
*/
nextSibling: RNode|null;
removeChild(oldChild: RNode): void;
/**
* Removes a child from the current node and returns the removed node
* @param oldChild the child node to remove
*/
removeChild(oldChild: RNode): RNode;
/**
* Insert a child node.

View File

@ -41,8 +41,8 @@ export const INJECTOR = 10;
export const RENDERER_FACTORY = 11;
export const RENDERER = 12;
export const SANITIZER = 13;
export const TAIL = 14;
export const CONTAINER_INDEX = 15;
export const CHILD_HEAD = 14;
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. */
@ -86,7 +86,7 @@ export interface LView extends Array<any> {
* This is the "insertion" view for embedded views. This allows us to properly
* destroy embedded views.
*/
[PARENT]: LView|null;
[PARENT]: LView|LContainer|null;
/**
*
@ -168,17 +168,7 @@ export interface LView extends Array<any> {
* The tail allows us to quickly add a new state to the end of the view list
* without having to propagate starting from the first child.
*/
[TAIL]: LView|LContainer|null;
/**
* The index of the parent container's host node. Applicable only to embedded views that
* have been inserted dynamically. Will be -1 for component views and inline views.
*
* This is necessary to jump from dynamically created embedded views to their parent
* containers because their parent cannot be stored on the TViewNode (views may be inserted
* in multiple containers, so the parent cannot be shared between view instances).
*/
[CONTAINER_INDEX]: number;
[CHILD_TAIL]: LView|LContainer|null;
/**
* Stores QueryLists associated with content queries of a directive. This data structure is