refactor(ivy): remove LNode.tNode (#25958)

PR Close #25958
This commit is contained in:
Kara Erickson
2018-09-13 16:07:23 -07:00
committed by Ben Lesh
parent 47f4412650
commit aedebaf025
21 changed files with 755 additions and 639 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {LElementNode, LViewNode} from './node';
import {LElementNode} from './node';
import {LQueries} from './query';
import {LViewData, NEXT, PARENT, QUERIES} from './view';

View File

@ -11,7 +11,7 @@ import {ElementRef} from '../../linker/element_ref';
import {TemplateRef} from '../../linker/template_ref';
import {ViewContainerRef} from '../../linker/view_container_ref';
import {LContainerNode, LElementContainerNode, LElementNode} from './node';
import {LContainerNode, LElementContainerNode, LElementNode, TContainerNode, TElementNode, TNode} from './node';
export interface LInjector {
/**
@ -28,6 +28,8 @@ export interface LInjector {
*/
readonly node: LElementNode|LElementContainerNode|LContainerNode;
readonly tNode: TNode;
/**
* The following bloom filter determines whether a directive is available
* on the associated node or not. This prevents us from searching the directives

View File

@ -81,7 +81,6 @@ export interface LNode {
*/
readonly data: LViewData|LContainer|null;
/**
* Each node belongs to a view.
*
@ -92,12 +91,6 @@ export interface LNode {
/** The injector associated with this node. Necessary for DI. */
nodeInjector: LInjector|null;
/**
* Pointer to the corresponding TNode object, which stores static
* data about this node.
*/
tNode: TNode;
/**
* A pointer to an LContainerNode created by directives requesting ViewContainerRef
*/
@ -385,13 +378,13 @@ export interface TNode {
export interface TElementNode extends TNode {
/** Index in the data[] array */
index: number;
child: TElementNode|TTextNode|TContainerNode|TProjectionNode|null;
child: TElementNode|TTextNode|TElementContainerNode|TContainerNode|TProjectionNode|null;
/**
* Element nodes will have parents unless they are the first node of a component or
* embedded view (which means their parent is in a different view and must be
* retrieved using LView.node).
* retrieved using viewData[HOST_NODE]).
*/
parent: TElementNode|null;
parent: TElementNode|TElementContainerNode|null;
tViews: null;
/**
@ -412,7 +405,7 @@ export interface TTextNode extends TNode {
* embedded view (which means their parent is in a different view and must be
* retrieved using LView.node).
*/
parent: TElementNode|null;
parent: TElementNode|TElementContainerNode|null;
tViews: null;
projection: null;
}
@ -434,16 +427,27 @@ export interface TContainerNode extends TNode {
* - They are the first node of a component or embedded view
* - They are dynamically created
*/
parent: TElementNode|null;
parent: TElementNode|TElementContainerNode|null;
tViews: TView|TView[]|null;
projection: null;
}
/** Static data for an LElementContainerNode */
export interface TElementContainerNode extends TNode {
/** Index in the LViewData[] array. */
index: number;
child: TElementNode|TTextNode|TContainerNode|TElementContainerNode|TProjectionNode|null;
parent: TElementNode|TElementContainerNode|null;
tViews: null;
projection: null;
}
/** Static data for an LViewNode */
export interface TViewNode extends TNode {
/** If -1, it's a dynamically created view. Otherwise, it is the view block ID. */
index: number;
child: TElementNode|TTextNode|TContainerNode|TProjectionNode|null;
child: TElementNode|TTextNode|TElementContainerNode|TContainerNode|TProjectionNode|null;
parent: TContainerNode|null;
tViews: null;
projection: null;
@ -458,7 +462,7 @@ export interface TProjectionNode extends TNode {
* or embedded view (which means their parent is in a different view and must be
* retrieved using LView.node).
*/
parent: TElementNode|null;
parent: TElementNode|TElementContainerNode|null;
tViews: null;
/** Index of the projection node. (See TNode.projection for more info.) */
@ -536,4 +540,4 @@ export type LNodeWithLocalRefs = LContainerNode | LElementNode | LElementContain
* - `<div #nativeDivEl>` - `nativeDivEl` should point to the native `<div>` element;
* - `<ng-template #tplRef>` - `tplRef` should point to the `TemplateRef` instance;
*/
export type LocalRefExtractor = (lNode: LNodeWithLocalRefs) => any;
export type LocalRefExtractor = (lNode: LNodeWithLocalRefs, tNode: TNode) => any;

View File

@ -8,7 +8,7 @@
import {QueryList} from '../../linker';
import {Type} from '../../type';
import {LNode} from './node';
import {TNode} from './node';
/** Used for tracking queries (e.g. ViewChild, ContentChild). */
export interface LQueries {
@ -30,10 +30,10 @@ export interface LQueries {
clone(): LQueries;
/**
* Notify `LQueries` that a new `LNode` has been created and needs to be added to query results
* Notify `LQueries` that a new `TNode` has been created and needs to be added to query results
* if matching query predicate.
*/
addNode(node: LNode): LQueries|null;
addNode(tNode: TNode): LQueries|null;
/**
* Notify `LQueries` that a new LContainer was added to ivy data structures. As a result we need

View File

@ -94,15 +94,16 @@ export interface LViewData extends Array<any> {
[FLAGS]: LViewFlags;
/**
* Pointer to the `LViewNode` or `LElementNode` which represents the root of the view.
* Pointer to the `TViewNode` or `TElementNode` which represents the root of the view.
*
* If `LViewNode`, this is an embedded view of a container. We need this to be able to
* If `TViewNode`, this is an embedded view of a container. We need this to be able to
* efficiently find the `LViewNode` when inserting the view into an anchor.
*
* If `LElementNode`, this is the LView of a component.
* If `TElementNode`, this is the LView of a component.
*
* If null, this is the root view of an application (root component is in this view).
*/
// TODO(kara): Replace with index
[HOST_NODE]: LViewNode|LElementNode;
[HOST_NODE]: TViewNode|TElementNode|null;
/**
* The binding index we should access next.
@ -213,16 +214,16 @@ export const enum LViewFlags {
* back into the parent view, `data` will be defined and `creationMode` will be
* improperly reported as false.
*/
CreationMode = 0b000001,
CreationMode = 0b0000001,
/** Whether this view has default change detection strategy (checks always) or onPush */
CheckAlways = 0b000010,
CheckAlways = 0b0000010,
/** Whether or not this view is currently dirty (needing check) */
Dirty = 0b000100,
Dirty = 0b0000100,
/** Whether or not this view is currently attached to change detection tree. */
Attached = 0b001000,
Attached = 0b0001000,
/**
* Whether or not the init hooks have run.
@ -231,10 +232,13 @@ export const enum LViewFlags {
* runs OR the first cR() instruction that runs (so inits are run for the top level view before
* any embedded views).
*/
RunInit = 0b010000,
RunInit = 0b0010000,
/** Whether or not this view is destroyed. */
Destroyed = 0b100000,
Destroyed = 0b0100000,
/** Whether or not this view is the root view */
IsRoot = 0b1000000,
}
/**