refactor(ivy): queries should not rely on LNode (#25415)

PR Close #25415
This commit is contained in:
Kara Erickson
2018-08-09 10:00:07 -07:00
committed by Ben Lesh
parent 209cc7e1b0
commit 2b128a47b9
8 changed files with 384 additions and 202 deletions

View File

@ -42,8 +42,11 @@ export const enum TNodeFlags {
/** This bit is set if the node has been projected */
isProjected = 0b00000000000000000010000000000000,
/** This bit is set if the node has any content queries */
hasContentQuery = 0b00000000000000000100000000000000,
/** The index of the first directive on this node is encoded on the most significant bits */
DirectiveStartingIndexShift = 14,
DirectiveStartingIndexShift = 15,
}
/**
@ -89,13 +92,6 @@ export interface LNode {
/** The injector associated with this node. Necessary for DI. */
nodeInjector: LInjector|null;
/**
* Optional set of queries that track query-related events for this node.
*
* If present the node creation/updates are reported to the `LQueries`.
*/
queries: LQueries|null;
/**
* Pointer to the corresponding TNode object, which stores static
* data about this node.

View File

@ -13,26 +13,27 @@ import {LNode} from './node';
/** Used for tracking queries (e.g. ViewChild, ContentChild). */
export interface LQueries {
/**
* Ask queries to prepare copy of itself. This assures that tracking new queries on child nodes
* The parent LQueries instance.
*
* When there is a content query, a new LQueries instance is created to avoid mutating any
* existing LQueries. After we are done searching content children, the parent property allows
* us to traverse back up to the original LQueries instance to continue to search for matches
* in the main view.
*/
parent: LQueries|null;
/**
* Ask queries to prepare copy of itself. This assures that tracking new queries on content nodes
* doesn't mutate list of queries tracked on a parent node. We will clone LQueries before
* constructing content queries.
*/
clone(): LQueries|null;
/**
* Used to ask queries if those should be cloned to the child element.
*
* For example in the case of deep queries the `child()` returns
* queries for the child node. In case of shallow queries it returns
* `null`.
*/
child(): LQueries|null;
clone(): LQueries;
/**
* Notify `LQueries` that a new `LNode` has been created and needs to be added to query results
* if matching query predicate.
*/
addNode(node: LNode): void;
addNode(node: LNode): LQueries|null;
/**
* Notify `LQueries` that a new LContainer was added to ivy data structures. As a result we need