fix(ivy): support queries for views inserted in lifecycle hooks (#24587)

Closes #23707

PR Close #24587
This commit is contained in:
Pawel Kozlowski
2018-06-19 17:58:42 +02:00
committed by Miško Hevery
parent 1e6a226703
commit 3e1a3b2e32
13 changed files with 1243 additions and 862 deletions

View File

@ -18,6 +18,11 @@ export type ComponentTemplate<T> = {
(rf: RenderFlags, ctx: T): void; ngPrivateData?: never;
};
/**
* Definition of what a query function should look like.
*/
export type ComponentQuery<T> = ComponentTemplate<T>;
/**
* Flags passed into template functions to determine which blocks (i.e. creation, update)
* should be executed.
@ -153,15 +158,16 @@ export type ComponentDefInternal<T> = ComponentDef<T, string>;
export interface ComponentDef<T, Selector extends string> extends DirectiveDef<T, Selector> {
/**
* The View template of the component.
*
* NOTE: only used with component directives.
*/
readonly template: ComponentTemplate<T>;
/**
* Query-related instructions for a component.
*/
readonly viewQuery: ComponentQuery<T>|null;
/**
* Renderer type data of the component.
*
* NOTE: only used with component directives.
*/
readonly rendererType: RendererType2|null;

View File

@ -10,7 +10,7 @@ import {Injector} from '../../di/injector';
import {Sanitizer} from '../../sanitization/security';
import {LContainer} from './container';
import {ComponentTemplate, DirectiveDefInternal, DirectiveDefList, PipeDef, PipeDefList} from './definition';
import {ComponentQuery, ComponentTemplate, DirectiveDefInternal, DirectiveDefList, PipeDef, PipeDefList} from './definition';
import {LElementNode, LViewNode, TNode} from './node';
import {LQueries} from './query';
import {Renderer3} from './renderer';
@ -200,6 +200,11 @@ export interface TView {
*/
template: ComponentTemplate<{}>|null;
/**
* A function containing query-related instructions.
*/
viewQuery: ComponentQuery<{}>|null;
/**
* Pointer to the `TNode` that represents the root of the view.
*