refactor(ivy): remove content query creation from directive factories (#24811)

PR Close #24811
This commit is contained in:
Pawel Kozlowski
2018-07-10 10:43:07 +02:00
committed by Matias Niemelä
parent 328971ffcc
commit 0399c6972a
11 changed files with 205 additions and 75 deletions

View File

@ -122,6 +122,14 @@ export interface DirectiveDef<T, Selector extends string> {
*/
factory(): T|[T];
/**
* Function to create instances of content queries associated with a given directive.
*/
contentQueries: (() => void)|null;
/** Refreshes content queries associated with directives in a given view */
contentQueriesRefresh: ((directiveIndex: number, queryIndex: number) => void)|null;
/** Refreshes host bindings on the associated directive. */
hostBindings: ((directiveIndex: number, elementIndex: number) => void)|null;

View File

@ -7,6 +7,7 @@
*/
import {Injector} from '../../di/injector';
import {QueryList} from '../../linker';
import {Sanitizer} from '../../sanitization/security';
import {LContainer} from './container';
@ -16,7 +17,7 @@ import {LQueries} from './query';
import {Renderer3} from './renderer';
/** Size of LViewData's header. Necessary to adjust for it when setting slots. */
export const HEADER_OFFSET = 15;
export const HEADER_OFFSET = 16;
// Below are constants for LViewData indices to help us look up LViewData members
// without having to remember the specific indices.
@ -36,6 +37,7 @@ export const RENDERER = 11;
export const SANITIZER = 12;
export const TAIL = 13;
export const CONTAINER_INDEX = 14;
export const CONTENT_QUERIES = 15;
/**
* `LViewData` stores all of the information needed to process the instructions as
@ -153,6 +155,13 @@ export interface LViewData extends Array<any> {
* in multiple containers, so the parent cannot be shared between view instances).
*/
[CONTAINER_INDEX]: number;
/**
* Stores QueryLists associated with content queries of a directive. This data structure is
* filled-in as part of a directive creation process and is later used to retrieve a QueryList to
* be refreshed.
*/
[CONTENT_QUERIES]: QueryList<any>[]|null;
}
/** Flags associated with an LView (saved in LViewData[FLAGS]) */
@ -413,6 +422,15 @@ export interface TView {
* they will be fed into instructions that expect the raw index (e.g. elementProperty)
*/
hostBindings: number[]|null;
/**
* A list of indices for child directives that have content queries.
*
* Even indices: Directive indices
* Odd indices: Starting index of content queries (stored in CONTENT_QUERIES) for this directive
*/
contentQueries: number[]|null;
}
/**