parent
79cecf9a5e
commit
524e5d8ae7
|
@ -271,9 +271,9 @@ export function executeInitAndContentHooks(): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createLView(
|
export function createLView<T>(
|
||||||
viewId: number, renderer: Renderer3, tView: TView, template: ComponentTemplate<any>| null,
|
viewId: number, renderer: Renderer3, tView: TView, template: ComponentTemplate<T>| null,
|
||||||
context: any | null, flags: LViewFlags): LView {
|
context: T | null, flags: LViewFlags): LView {
|
||||||
const newView = {
|
const newView = {
|
||||||
parent: currentView,
|
parent: currentView,
|
||||||
id: viewId, // -1 for component views
|
id: viewId, // -1 for component views
|
||||||
|
@ -1174,9 +1174,9 @@ export function directiveCreate<T>(
|
||||||
ngDevMode && assertNotNull(previousOrParentNode.tNode, 'previousOrParentNode.tNode');
|
ngDevMode && assertNotNull(previousOrParentNode.tNode, 'previousOrParentNode.tNode');
|
||||||
const tNode: TNode|null = previousOrParentNode.tNode !;
|
const tNode: TNode|null = previousOrParentNode.tNode !;
|
||||||
|
|
||||||
const isComponent = (directiveDef as ComponentDef<any>).template;
|
const isComponent = (directiveDef as ComponentDef<T>).template;
|
||||||
if (isComponent) {
|
if (isComponent) {
|
||||||
addComponentLogic(index, elementIndex, directive, directiveDef as ComponentDef<any>);
|
addComponentLogic(index, elementIndex, directive, directiveDef as ComponentDef<T>);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstTemplatePass) {
|
if (firstTemplatePass) {
|
||||||
|
@ -1188,14 +1188,14 @@ export function directiveCreate<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tNode && tNode.attrs) {
|
if (tNode && tNode.attrs) {
|
||||||
setInputsFromAttrs<T>(index, instance, directiveDef.inputs, tNode);
|
setInputsFromAttrs(index, instance, directiveDef.inputs, tNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addComponentLogic<T>(
|
function addComponentLogic<T>(
|
||||||
index: number, elementIndex: number, instance: T, def: ComponentDef<any>): void {
|
index: number, elementIndex: number, instance: T, def: ComponentDef<T>): void {
|
||||||
const tView = getOrCreateTView(def.template, def.directiveDefs, def.pipeDefs);
|
const tView = getOrCreateTView(def.template, def.directiveDefs, def.pipeDefs);
|
||||||
|
|
||||||
// Only component views should be added to the view tree directly. Embedded views are
|
// Only component views should be added to the view tree directly. Embedded views are
|
||||||
|
@ -1221,7 +1221,7 @@ function addComponentLogic<T>(
|
||||||
* current Angular. Example: local refs and inputs on root component.
|
* current Angular. Example: local refs and inputs on root component.
|
||||||
*/
|
*/
|
||||||
export function baseDirectiveCreate<T>(
|
export function baseDirectiveCreate<T>(
|
||||||
index: number, directive: T, directiveDef: DirectiveDef<T>| ComponentDef<any>): T {
|
index: number, directive: T, directiveDef: DirectiveDef<T>| ComponentDef<T>): T {
|
||||||
ngDevMode &&
|
ngDevMode &&
|
||||||
assertNull(currentView.bindingStartIndex, 'directives should be created before any bindings');
|
assertNull(currentView.bindingStartIndex, 'directives should be created before any bindings');
|
||||||
ngDevMode && assertPreviousIsParent();
|
ngDevMode && assertPreviousIsParent();
|
||||||
|
@ -1558,10 +1558,10 @@ export function componentRefresh<T>(directiveIndex: number, elementIndex: number
|
||||||
// Only attached CheckAlways components or attached, dirty OnPush components should be checked
|
// Only attached CheckAlways components or attached, dirty OnPush components should be checked
|
||||||
if (viewAttached(hostView) && hostView.flags & (LViewFlags.CheckAlways | LViewFlags.Dirty)) {
|
if (viewAttached(hostView) && hostView.flags & (LViewFlags.CheckAlways | LViewFlags.Dirty)) {
|
||||||
ngDevMode && assertDataInRange(directiveIndex, directives !);
|
ngDevMode && assertDataInRange(directiveIndex, directives !);
|
||||||
const def = currentView.tView.directives ![directiveIndex] as ComponentDef<any>;
|
const def = currentView.tView.directives ![directiveIndex] as ComponentDef<T>;
|
||||||
|
|
||||||
detectChangesInternal(
|
detectChangesInternal(
|
||||||
hostView, element, def, getDirectiveInstance<T>(directives ![directiveIndex]));
|
hostView, element, def, getDirectiveInstance(directives ![directiveIndex]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1906,7 +1906,7 @@ function throwErrorIfNoChangesMode(oldValue: any, currValue: any): never|void {
|
||||||
|
|
||||||
/** Checks the view of the component provided. Does not gate on dirty checks or execute doCheck. */
|
/** Checks the view of the component provided. Does not gate on dirty checks or execute doCheck. */
|
||||||
export function detectChangesInternal<T>(
|
export function detectChangesInternal<T>(
|
||||||
hostView: LView, hostNode: LElementNode, def: ComponentDef<any>, component: T) {
|
hostView: LView, hostNode: LElementNode, def: ComponentDef<T>, component: T) {
|
||||||
const oldView = enterView(hostView, hostNode);
|
const oldView = enterView(hostView, hostNode);
|
||||||
const template = def.template;
|
const template = def.template;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue