refactor(ivy): rename `tView.firstTemplatePass` to `tView.firstCreatePass` (#31270)
PR Close #31270
This commit is contained in:
parent
91147ade2e
commit
9c13d6e8e6
|
@ -97,24 +97,24 @@ Here is an example of code which breaks the inlining and a way to fix it.
|
||||||
```
|
```
|
||||||
export function i18nStart(index: number, message: string, subTemplateIndex?: number): void {
|
export function i18nStart(index: number, message: string, subTemplateIndex?: number): void {
|
||||||
const tView = getTView();
|
const tView = getTView();
|
||||||
if (tView.firstTemplatePass && tView.data[index + HEADER_OFFSET] === null) {
|
if (tView.firstCreatePass && tView.data[index + HEADER_OFFSET] === null) {
|
||||||
// LOTS OF CODE HERE WHICH PREVENTS INLINING.
|
// LOTS OF CODE HERE WHICH PREVENTS INLINING.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice that the above function almost never runs because `tView.firstTemplatePass` is usually false.
|
Notice that the above function almost never runs because `tView.firstCreatePass` is usually false.
|
||||||
The application would benefit from inlining, but the large code inside `if` prevents it.
|
The application would benefit from inlining, but the large code inside `if` prevents it.
|
||||||
Simple refactoring will fix it.
|
Simple refactoring will fix it.
|
||||||
|
|
||||||
```
|
```
|
||||||
export function i18nStart(index: number, message: string, subTemplateIndex?: number): void {
|
export function i18nStart(index: number, message: string, subTemplateIndex?: number): void {
|
||||||
const tView = getTView();
|
const tView = getTView();
|
||||||
if (tView.firstTemplatePass && tView.data[index + HEADER_OFFSET] === null) {
|
if (tView.firstCreatePass && tView.data[index + HEADER_OFFSET] === null) {
|
||||||
i18nStartFirstTemplatePass(tView, index, message, subTemplateIndex)
|
i18nStartfirstCreatePass(tView, index, message, subTemplateIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function i18nStartFirstTemplatePass(tView: TView, index: number, message: string, subTemplateIndex?: number): void {
|
export function i18nStartfirstCreatePass(tView: TView, index: number, message: string, subTemplateIndex?: number): void {
|
||||||
// LOTS OF CODE HERE WHICH PREVENTS INLINING.
|
// LOTS OF CODE HERE WHICH PREVENTS INLINING.
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -68,7 +68,7 @@ export function assertLView(value: any) {
|
||||||
assertEqual(isLView(value), true, 'Expecting LView');
|
assertEqual(isLView(value), true, 'Expecting LView');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function assertFirstTemplatePass(tView: TView, errMessage?: string) {
|
export function assertFirstCreatePass(tView: TView, errMessage?: string) {
|
||||||
assertEqual(
|
assertEqual(
|
||||||
tView.firstTemplatePass, true, errMessage || 'Should only be called in first template pass.');
|
tView.firstCreatePass, true, errMessage || 'Should only be called in first create pass.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ export function createRootComponentView(
|
||||||
rootView, getOrCreateTView(def), null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways,
|
rootView, getOrCreateTView(def), null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways,
|
||||||
rootView[HEADER_OFFSET], tNode, rendererFactory, renderer, sanitizer);
|
rootView[HEADER_OFFSET], tNode, rendererFactory, renderer, sanitizer);
|
||||||
|
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
||||||
markAsComponentHost(tView, tNode);
|
markAsComponentHost(tView, tNode);
|
||||||
initNodeFlags(tNode, rootView.length, 1);
|
initNodeFlags(tNode, rootView.length, 1);
|
||||||
|
@ -209,14 +209,14 @@ export function createRootComponent<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootTNode = getPreviousOrParentTNode();
|
const rootTNode = getPreviousOrParentTNode();
|
||||||
if (tView.firstTemplatePass && componentDef.hostBindings) {
|
if (tView.firstCreatePass && componentDef.hostBindings) {
|
||||||
const elementIndex = rootTNode.index - HEADER_OFFSET;
|
const elementIndex = rootTNode.index - HEADER_OFFSET;
|
||||||
setActiveHostElement(elementIndex);
|
setActiveHostElement(elementIndex);
|
||||||
incrementActiveDirectiveId();
|
incrementActiveDirectiveId();
|
||||||
|
|
||||||
const expando = tView.expandoInstructions !;
|
const expando = tView.expandoInstructions !;
|
||||||
invokeHostBindingsInCreationMode(
|
invokeHostBindingsInCreationMode(
|
||||||
componentDef, expando, component, rootTNode, tView.firstTemplatePass);
|
componentDef, expando, component, rootTNode, tView.firstCreatePass);
|
||||||
|
|
||||||
setActiveHostElement(null);
|
setActiveHostElement(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ let nextNgElementId = 0;
|
||||||
*/
|
*/
|
||||||
export function bloomAdd(
|
export function bloomAdd(
|
||||||
injectorIndex: number, tView: TView, type: Type<any>| InjectionToken<any>| string): void {
|
injectorIndex: number, tView: TView, type: Type<any>| InjectionToken<any>| string): void {
|
||||||
ngDevMode && assertEqual(tView.firstTemplatePass, true, 'expected firstTemplatePass to be true');
|
ngDevMode && assertEqual(tView.firstCreatePass, true, 'expected firstCreatePass to be true');
|
||||||
let id: number|undefined =
|
let id: number|undefined =
|
||||||
typeof type !== 'string' ? (type as any)[NG_ELEMENT_ID] : type.charCodeAt(0) || 0;
|
typeof type !== 'string' ? (type as any)[NG_ELEMENT_ID] : type.charCodeAt(0) || 0;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ export function getOrCreateNodeInjectorForNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
const tView = hostView[TVIEW];
|
const tView = hostView[TVIEW];
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
tNode.injectorIndex = hostView.length;
|
tNode.injectorIndex = hostView.length;
|
||||||
insertBloom(tView.data, tNode); // foundation for node bloom
|
insertBloom(tView.data, tNode); // foundation for node bloom
|
||||||
insertBloom(hostView, null); // foundation for cumulative bloom
|
insertBloom(hostView, null); // foundation for cumulative bloom
|
||||||
|
|
|
@ -44,7 +44,7 @@ export function providersResolver<T>(
|
||||||
def: DirectiveDef<T>, providers: Provider[], viewProviders: Provider[]): void {
|
def: DirectiveDef<T>, providers: Provider[], viewProviders: Provider[]): void {
|
||||||
const lView = getLView();
|
const lView = getLView();
|
||||||
const tView: TView = lView[TVIEW];
|
const tView: TView = lView[TVIEW];
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
const isComponent = isComponentDef(def);
|
const isComponent = isComponentDef(def);
|
||||||
|
|
||||||
// The list of view providers is processed first, and the flags are updated
|
// The list of view providers is processed first, and the flags are updated
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {assertEqual, assertNotEqual} from '../util/assert';
|
import {assertEqual, assertNotEqual} from '../util/assert';
|
||||||
|
|
||||||
import {assertFirstTemplatePass} from './assert';
|
import {assertFirstCreatePass} from './assert';
|
||||||
import {DirectiveDef} from './interfaces/definition';
|
import {DirectiveDef} from './interfaces/definition';
|
||||||
import {TNode} from './interfaces/node';
|
import {TNode} from './interfaces/node';
|
||||||
import {FLAGS, HookData, InitPhaseState, LView, LViewFlags, PREORDER_HOOK_FLAGS, PreOrderHookFlags, TView} from './interfaces/view';
|
import {FLAGS, HookData, InitPhaseState, LView, LViewFlags, PREORDER_HOOK_FLAGS, PreOrderHookFlags, TView} from './interfaces/view';
|
||||||
|
@ -36,7 +36,7 @@ import {getCheckNoChangesMode} from './state';
|
||||||
export function registerPreOrderHooks(
|
export function registerPreOrderHooks(
|
||||||
directiveIndex: number, directiveDef: DirectiveDef<any>, tView: TView, nodeIndex: number,
|
directiveIndex: number, directiveDef: DirectiveDef<any>, tView: TView, nodeIndex: number,
|
||||||
initialPreOrderHooksLength: number, initialPreOrderCheckHooksLength: number): void {
|
initialPreOrderHooksLength: number, initialPreOrderCheckHooksLength: number): void {
|
||||||
ngDevMode && assertFirstTemplatePass(tView);
|
ngDevMode && assertFirstCreatePass(tView);
|
||||||
const {onChanges, onInit, doCheck} = directiveDef;
|
const {onChanges, onInit, doCheck} = directiveDef;
|
||||||
if (initialPreOrderHooksLength >= 0 &&
|
if (initialPreOrderHooksLength >= 0 &&
|
||||||
(!tView.preOrderHooks || initialPreOrderHooksLength === tView.preOrderHooks.length) &&
|
(!tView.preOrderHooks || initialPreOrderHooksLength === tView.preOrderHooks.length) &&
|
||||||
|
@ -85,7 +85,7 @@ export function registerPreOrderHooks(
|
||||||
* @param tNode The TNode whose directives are to be searched for hooks to queue
|
* @param tNode The TNode whose directives are to be searched for hooks to queue
|
||||||
*/
|
*/
|
||||||
export function registerPostOrderHooks(tView: TView, tNode: TNode): void {
|
export function registerPostOrderHooks(tView: TView, tNode: TNode): void {
|
||||||
ngDevMode && assertFirstTemplatePass(tView);
|
ngDevMode && assertFirstCreatePass(tView);
|
||||||
// It's necessary to loop through the directives at elementEnd() (rather than processing in
|
// It's necessary to loop through the directives at elementEnd() (rather than processing in
|
||||||
// directiveCreate) so we can preserve the current hook order. Content, view, and destroy
|
// directiveCreate) so we can preserve the current hook order. Content, view, and destroy
|
||||||
// hooks for projected components and directives must be called *before* their hosts.
|
// hooks for projected components and directives must be called *before* their hosts.
|
||||||
|
|
|
@ -366,7 +366,7 @@ export function ɵɵi18nStart(index: number, message: string, subTemplateIndex?:
|
||||||
i18nIndexStack[++i18nIndexStackPointer] = index;
|
i18nIndexStack[++i18nIndexStackPointer] = index;
|
||||||
// We need to delay projections until `i18nEnd`
|
// We need to delay projections until `i18nEnd`
|
||||||
setDelayProjection(true);
|
setDelayProjection(true);
|
||||||
if (tView.firstTemplatePass && tView.data[index + HEADER_OFFSET] === null) {
|
if (tView.firstCreatePass && tView.data[index + HEADER_OFFSET] === null) {
|
||||||
i18nStartFirstPass(lView, tView, index, message, subTemplateIndex);
|
i18nStartFirstPass(lView, tView, index, message, subTemplateIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1006,7 @@ function i18nAttributesFirstPass(lView: LView, tView: TView, index: number, valu
|
||||||
// Even indexes are text (including bindings)
|
// Even indexes are text (including bindings)
|
||||||
const hasBinding = !!value.match(BINDING_REGEXP);
|
const hasBinding = !!value.match(BINDING_REGEXP);
|
||||||
if (hasBinding) {
|
if (hasBinding) {
|
||||||
if (tView.firstTemplatePass && tView.data[index + HEADER_OFFSET] === null) {
|
if (tView.firstCreatePass && tView.data[index + HEADER_OFFSET] === null) {
|
||||||
addAllToArray(
|
addAllToArray(
|
||||||
generateBindingUpdateOpCodes(value, previousElementIndex, attrName), updateOpCodes);
|
generateBindingUpdateOpCodes(value, previousElementIndex, attrName), updateOpCodes);
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1027,7 @@ function i18nAttributesFirstPass(lView: LView, tView: TView, index: number, valu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tView.firstTemplatePass && tView.data[index + HEADER_OFFSET] === null) {
|
if (tView.firstCreatePass && tView.data[index + HEADER_OFFSET] === null) {
|
||||||
tView.data[index + HEADER_OFFSET] = updateOpCodes;
|
tView.data[index + HEADER_OFFSET] = updateOpCodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {NO_CHANGE} from '../tokens';
|
||||||
export function ɵɵallocHostVars(count: number): void {
|
export function ɵɵallocHostVars(count: number): void {
|
||||||
const lView = getLView();
|
const lView = getLView();
|
||||||
const tView = lView[TVIEW];
|
const tView = lView[TVIEW];
|
||||||
if (!tView.firstTemplatePass) return;
|
if (!tView.firstCreatePass) return;
|
||||||
queueHostBindingForCheck(tView, getCurrentDirectiveDef() !, count);
|
queueHostBindingForCheck(tView, getCurrentDirectiveDef() !, count);
|
||||||
prefillHostVars(tView, lView, count);
|
prefillHostVars(tView, lView, count);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export function ɵɵallocHostVars(count: number): void {
|
||||||
function queueHostBindingForCheck(
|
function queueHostBindingForCheck(
|
||||||
tView: TView, def: DirectiveDef<any>| ComponentDef<any>, hostVars: number): void {
|
tView: TView, def: DirectiveDef<any>| ComponentDef<any>, hostVars: number): void {
|
||||||
ngDevMode &&
|
ngDevMode &&
|
||||||
assertEqual(tView.firstTemplatePass, true, 'Should only be called in first template pass.');
|
assertEqual(tView.firstCreatePass, true, 'Should only be called in first create pass.');
|
||||||
const expando = tView.expandoInstructions !;
|
const expando = tView.expandoInstructions !;
|
||||||
const length = expando.length;
|
const length = expando.length;
|
||||||
// Check whether a given `hostBindings` function already exists in expandoInstructions,
|
// Check whether a given `hostBindings` function already exists in expandoInstructions,
|
||||||
|
@ -56,7 +56,7 @@ function queueHostBindingForCheck(
|
||||||
*/
|
*/
|
||||||
function prefillHostVars(tView: TView, lView: LView, totalHostVars: number): void {
|
function prefillHostVars(tView: TView, lView: LView, totalHostVars: number): void {
|
||||||
ngDevMode &&
|
ngDevMode &&
|
||||||
assertEqual(tView.firstTemplatePass, true, 'Should only be called in first template pass.');
|
assertEqual(tView.firstCreatePass, true, 'Should only be called in first create pass.');
|
||||||
for (let i = 0; i < totalHostVars; i++) {
|
for (let i = 0; i < totalHostVars; i++) {
|
||||||
lView.push(NO_CHANGE);
|
lView.push(NO_CHANGE);
|
||||||
tView.blueprint.push(NO_CHANGE);
|
tView.blueprint.push(NO_CHANGE);
|
||||||
|
|
|
@ -38,7 +38,7 @@ export function ɵɵcontainer(index: number): void {
|
||||||
const lView = getLView();
|
const lView = getLView();
|
||||||
const tNode = containerInternal(lView, index, null, null);
|
const tNode = containerInternal(lView, index, null, null);
|
||||||
|
|
||||||
if (lView[TVIEW].firstTemplatePass) {
|
if (lView[TVIEW].firstCreatePass) {
|
||||||
tNode.tViews = [];
|
tNode.tViews = [];
|
||||||
}
|
}
|
||||||
setIsNotParent();
|
setIsNotParent();
|
||||||
|
@ -75,8 +75,8 @@ export function ɵɵtemplate(
|
||||||
const tContainerNode = containerInternal(
|
const tContainerNode = containerInternal(
|
||||||
lView, index, tagName || null, getConstant(tViewConsts, attrsIndex) as TAttributes);
|
lView, index, tagName || null, getConstant(tViewConsts, attrsIndex) as TAttributes);
|
||||||
const localRefs = getConstant(tViewConsts, localRefsIndex) as string[];
|
const localRefs = getConstant(tViewConsts, localRefsIndex) as string[];
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
ngDevMode && ngDevMode.firstTemplatePass++;
|
ngDevMode && ngDevMode.firstCreatePass++;
|
||||||
resolveDirectives(tView, lView, tContainerNode, localRefs);
|
resolveDirectives(tView, lView, tContainerNode, localRefs);
|
||||||
registerPostOrderHooks(tView, tContainerNode);
|
registerPostOrderHooks(tView, tContainerNode);
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ export function ɵɵelementStart(
|
||||||
|
|
||||||
if (attrs != null) {
|
if (attrs != null) {
|
||||||
const lastAttrIndex = setUpAttributes(renderer, native, attrs);
|
const lastAttrIndex = setUpAttributes(renderer, native, attrs);
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex);
|
registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ export function ɵɵelementStart(
|
||||||
// flow through that (except for `[class.prop]` bindings). This also includes initial
|
// flow through that (except for `[class.prop]` bindings). This also includes initial
|
||||||
// static class values as well. (Note that this will be fixed once map-based `[style]`
|
// static class values as well. (Note that this will be fixed once map-based `[style]`
|
||||||
// and `[class]` bindings work for multiple directives.)
|
// and `[class]` bindings work for multiple directives.)
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
ngDevMode && ngDevMode.firstTemplatePass++;
|
ngDevMode && ngDevMode.firstCreatePass++;
|
||||||
const hasDirectives = resolveDirectives(tView, lView, tNode, localRefs);
|
const hasDirectives = resolveDirectives(tView, lView, tNode, localRefs);
|
||||||
ngDevMode && validateElement(lView, native, tNode, hasDirectives);
|
ngDevMode && validateElement(lView, native, tNode, hasDirectives);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ export function ɵɵelementEnd(): void {
|
||||||
|
|
||||||
decreaseElementDepthCount();
|
decreaseElementDepthCount();
|
||||||
|
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
registerPostOrderHooks(tView, previousOrParentTNode);
|
registerPostOrderHooks(tView, previousOrParentTNode);
|
||||||
if (isContentQueryHost(previousOrParentTNode)) {
|
if (isContentQueryHost(previousOrParentTNode)) {
|
||||||
tView.queries !.elementEnd(previousOrParentTNode);
|
tView.queries !.elementEnd(previousOrParentTNode);
|
||||||
|
@ -210,7 +210,7 @@ export function ɵɵelementHostAttrs(attrs: TAttributes) {
|
||||||
if (tNode.type === TNodeType.Element) {
|
if (tNode.type === TNodeType.Element) {
|
||||||
const native = getNativeByTNode(tNode, lView) as RElement;
|
const native = getNativeByTNode(tNode, lView) as RElement;
|
||||||
const lastAttrIndex = setUpAttributes(lView[RENDERER], native, attrs);
|
const lastAttrIndex = setUpAttributes(lView[RENDERER], native, attrs);
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
const stylingNeedsToBeRendered = registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex);
|
const stylingNeedsToBeRendered = registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex);
|
||||||
|
|
||||||
// this is only called during the first template pass in the
|
// this is only called during the first template pass in the
|
||||||
|
|
|
@ -57,7 +57,7 @@ export function ɵɵelementContainerStart(
|
||||||
const tNode =
|
const tNode =
|
||||||
getOrCreateTNode(tView, lView[T_HOST], index, TNodeType.ElementContainer, tagName, attrs);
|
getOrCreateTNode(tView, lView[T_HOST], index, TNodeType.ElementContainer, tagName, attrs);
|
||||||
|
|
||||||
if (attrs && tView.firstTemplatePass) {
|
if (attrs && tView.firstCreatePass) {
|
||||||
// While ng-container doesn't necessarily support styling, we use the style context to identify
|
// While ng-container doesn't necessarily support styling, we use the style context to identify
|
||||||
// and execute directives on the ng-container.
|
// and execute directives on the ng-container.
|
||||||
registerInitialStylingOnTNode(tNode, attrs, 0);
|
registerInitialStylingOnTNode(tNode, attrs, 0);
|
||||||
|
@ -66,8 +66,8 @@ export function ɵɵelementContainerStart(
|
||||||
appendChild(native, tNode, lView);
|
appendChild(native, tNode, lView);
|
||||||
attachPatchData(native, lView);
|
attachPatchData(native, lView);
|
||||||
|
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
ngDevMode && ngDevMode.firstTemplatePass++;
|
ngDevMode && ngDevMode.firstCreatePass++;
|
||||||
resolveDirectives(tView, lView, tNode, localRefs);
|
resolveDirectives(tView, lView, tNode, localRefs);
|
||||||
if (tView.queries) {
|
if (tView.queries) {
|
||||||
tView.queries.elementStart(tView, tNode);
|
tView.queries.elementStart(tView, tNode);
|
||||||
|
@ -103,7 +103,7 @@ export function ɵɵelementContainerEnd(): void {
|
||||||
|
|
||||||
ngDevMode && assertNodeType(previousOrParentTNode, TNodeType.ElementContainer);
|
ngDevMode && assertNodeType(previousOrParentTNode, TNodeType.ElementContainer);
|
||||||
|
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
registerPostOrderHooks(tView, previousOrParentTNode);
|
registerPostOrderHooks(tView, previousOrParentTNode);
|
||||||
if (isContentQueryHost(previousOrParentTNode)) {
|
if (isContentQueryHost(previousOrParentTNode)) {
|
||||||
tView.queries !.elementEnd(previousOrParentTNode);
|
tView.queries !.elementEnd(previousOrParentTNode);
|
||||||
|
|
|
@ -114,8 +114,8 @@ function listenerInternal(
|
||||||
eventTargetResolver?: GlobalTargetResolver): void {
|
eventTargetResolver?: GlobalTargetResolver): void {
|
||||||
const tView = lView[TVIEW];
|
const tView = lView[TVIEW];
|
||||||
const isTNodeDirectiveHost = isDirectiveHost(tNode);
|
const isTNodeDirectiveHost = isDirectiveHost(tNode);
|
||||||
const firstTemplatePass = tView.firstTemplatePass;
|
const firstCreatePass = tView.firstCreatePass;
|
||||||
const tCleanup: false|any[] = firstTemplatePass && (tView.cleanup || (tView.cleanup = []));
|
const tCleanup: false|any[] = firstCreatePass && (tView.cleanup || (tView.cleanup = []));
|
||||||
|
|
||||||
ngDevMode && assertNodeOfPossibleTypes(
|
ngDevMode && assertNodeOfPossibleTypes(
|
||||||
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
|
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
|
||||||
|
|
|
@ -85,7 +85,7 @@ export const TViewConstructor = class TView implements ITView {
|
||||||
public bindingStartIndex: number, //
|
public bindingStartIndex: number, //
|
||||||
public expandoStartIndex: number, //
|
public expandoStartIndex: number, //
|
||||||
public expandoInstructions: ExpandoInstructions|null, //
|
public expandoInstructions: ExpandoInstructions|null, //
|
||||||
public firstTemplatePass: boolean, //
|
public firstCreatePass: boolean, //
|
||||||
public firstUpdatePass: boolean, //
|
public firstUpdatePass: boolean, //
|
||||||
public staticViewQueries: boolean, //
|
public staticViewQueries: boolean, //
|
||||||
public staticContentQueries: boolean, //
|
public staticContentQueries: boolean, //
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {assertDataInRange, assertDefined, assertDomNode, assertEqual, assertGrea
|
||||||
import {createNamedArrayType} from '../../util/named_array_type';
|
import {createNamedArrayType} from '../../util/named_array_type';
|
||||||
import {initNgDevMode} from '../../util/ng_dev_mode';
|
import {initNgDevMode} from '../../util/ng_dev_mode';
|
||||||
import {normalizeDebugBindingName, normalizeDebugBindingValue} from '../../util/ng_reflect';
|
import {normalizeDebugBindingName, normalizeDebugBindingValue} from '../../util/ng_reflect';
|
||||||
import {assertFirstTemplatePass, assertLView} from '../assert';
|
import {assertFirstCreatePass, assertLView} from '../assert';
|
||||||
import {attachPatchData} from '../context_discovery';
|
import {attachPatchData} from '../context_discovery';
|
||||||
import {getFactoryDef} from '../definition';
|
import {getFactoryDef} from '../definition';
|
||||||
import {diPublicInInjector, getNodeInjectable, getOrCreateNodeInjectorForNode} from '../di';
|
import {diPublicInInjector, getNodeInjectable, getOrCreateNodeInjectorForNode} from '../di';
|
||||||
|
@ -279,7 +279,7 @@ export function allocExpando(view: LView, numSlotsToAlloc: number) {
|
||||||
numSlotsToAlloc, 0, 'The number of slots to alloc should be greater than 0');
|
numSlotsToAlloc, 0, 'The number of slots to alloc should be greater than 0');
|
||||||
if (numSlotsToAlloc > 0) {
|
if (numSlotsToAlloc > 0) {
|
||||||
const tView = view[TVIEW];
|
const tView = view[TVIEW];
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
for (let i = 0; i < numSlotsToAlloc; i++) {
|
for (let i = 0; i < numSlotsToAlloc; i++) {
|
||||||
tView.blueprint.push(null);
|
tView.blueprint.push(null);
|
||||||
tView.data.push(null);
|
tView.data.push(null);
|
||||||
|
@ -330,10 +330,10 @@ export function renderView<T>(lView: LView, tView: TView, context: T): void {
|
||||||
// This needs to be set before children are processed to support recursive components.
|
// This needs to be set before children are processed to support recursive components.
|
||||||
// This must be set to false immediately after the first creation run because in an
|
// This must be set to false immediately after the first creation run because in an
|
||||||
// ngFor loop, all the views will be created together before update mode runs and turns
|
// ngFor loop, all the views will be created together before update mode runs and turns
|
||||||
// off firstTemplatePass. If we don't set it here, instances will perform directive
|
// off firstCreatePass. If we don't set it here, instances will perform directive
|
||||||
// matching, etc again and again.
|
// matching, etc again and again.
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
tView.firstTemplatePass = false;
|
tView.firstCreatePass = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We resolve content queries specifically marked as `static` in creation mode. Dynamic
|
// We resolve content queries specifically marked as `static` in creation mode. Dynamic
|
||||||
|
@ -611,7 +611,7 @@ export function createTView(
|
||||||
bindingStartIndex, // bindingStartIndex: number,
|
bindingStartIndex, // bindingStartIndex: number,
|
||||||
initialViewLength, // expandoStartIndex: number,
|
initialViewLength, // expandoStartIndex: number,
|
||||||
null, // expandoInstructions: ExpandoInstructions|null,
|
null, // expandoInstructions: ExpandoInstructions|null,
|
||||||
true, // firstTemplatePass: boolean,
|
true, // firstCreatePass: boolean,
|
||||||
true, // firstUpdatePass: boolean,
|
true, // firstUpdatePass: boolean,
|
||||||
false, // staticViewQueries: boolean,
|
false, // staticViewQueries: boolean,
|
||||||
false, // staticContentQueries: boolean,
|
false, // staticContentQueries: boolean,
|
||||||
|
@ -643,7 +643,7 @@ export function createTView(
|
||||||
bindingStartIndex: bindingStartIndex,
|
bindingStartIndex: bindingStartIndex,
|
||||||
expandoStartIndex: initialViewLength,
|
expandoStartIndex: initialViewLength,
|
||||||
expandoInstructions: null,
|
expandoInstructions: null,
|
||||||
firstTemplatePass: true,
|
firstCreatePass: true,
|
||||||
firstUpdatePass: true,
|
firstUpdatePass: true,
|
||||||
staticViewQueries: false,
|
staticViewQueries: false,
|
||||||
staticContentQueries: false,
|
staticContentQueries: false,
|
||||||
|
@ -714,7 +714,7 @@ export function storeCleanupWithContext(lView: LView, context: any, cleanupFn: F
|
||||||
const lCleanup = getCleanup(lView);
|
const lCleanup = getCleanup(lView);
|
||||||
lCleanup.push(context);
|
lCleanup.push(context);
|
||||||
|
|
||||||
if (lView[TVIEW].firstTemplatePass) {
|
if (lView[TVIEW].firstCreatePass) {
|
||||||
getTViewCleanup(lView).push(cleanupFn, lCleanup.length - 1);
|
getTViewCleanup(lView).push(cleanupFn, lCleanup.length - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -730,7 +730,7 @@ export function storeCleanupWithContext(lView: LView, context: any, cleanupFn: F
|
||||||
export function storeCleanupFn(view: LView, cleanupFn: Function): void {
|
export function storeCleanupFn(view: LView, cleanupFn: Function): void {
|
||||||
getCleanup(view).push(cleanupFn);
|
getCleanup(view).push(cleanupFn);
|
||||||
|
|
||||||
if (view[TVIEW].firstTemplatePass) {
|
if (view[TVIEW].firstCreatePass) {
|
||||||
getTViewCleanup(view).push(view[CLEANUP] !.length - 1, null);
|
getTViewCleanup(view).push(view[CLEANUP] !.length - 1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -834,7 +834,7 @@ function generatePropertyAliases(
|
||||||
* Initialization is done for all directives matched on a given TNode.
|
* Initialization is done for all directives matched on a given TNode.
|
||||||
*/
|
*/
|
||||||
function initializeInputAndOutputAliases(tView: TView, tNode: TNode): void {
|
function initializeInputAndOutputAliases(tView: TView, tNode: TNode): void {
|
||||||
ngDevMode && assertFirstTemplatePass(tView);
|
ngDevMode && assertFirstCreatePass(tView);
|
||||||
|
|
||||||
const start = tNode.directiveStart;
|
const start = tNode.directiveStart;
|
||||||
const end = tNode.directiveEnd;
|
const end = tNode.directiveEnd;
|
||||||
|
@ -1025,7 +1025,7 @@ function warnAboutUnknownProperty(propName: string, tNode: TNode): void {
|
||||||
*/
|
*/
|
||||||
export function instantiateRootComponent<T>(tView: TView, lView: LView, def: ComponentDef<T>): T {
|
export function instantiateRootComponent<T>(tView: TView, lView: LView, def: ComponentDef<T>): T {
|
||||||
const rootTNode = getPreviousOrParentTNode();
|
const rootTNode = getPreviousOrParentTNode();
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
if (def.providersResolver) def.providersResolver(def);
|
if (def.providersResolver) def.providersResolver(def);
|
||||||
generateExpandoInstructionBlock(tView, rootTNode, 1);
|
generateExpandoInstructionBlock(tView, rootTNode, 1);
|
||||||
baseResolveDirective(tView, lView, def);
|
baseResolveDirective(tView, lView, def);
|
||||||
|
@ -1048,7 +1048,7 @@ export function resolveDirectives(
|
||||||
localRefs: string[] | null): boolean {
|
localRefs: string[] | null): boolean {
|
||||||
// Please make sure to have explicit type for `exportsMap`. Inferred type triggers bug in
|
// Please make sure to have explicit type for `exportsMap`. Inferred type triggers bug in
|
||||||
// tsickle.
|
// tsickle.
|
||||||
ngDevMode && assertFirstTemplatePass(tView);
|
ngDevMode && assertFirstCreatePass(tView);
|
||||||
|
|
||||||
if (!getBindingsEnabled()) return false;
|
if (!getBindingsEnabled()) return false;
|
||||||
|
|
||||||
|
@ -1105,7 +1105,7 @@ function instantiateAllDirectives(
|
||||||
tView: TView, lView: LView, tNode: TDirectiveHostNode, native: RNode) {
|
tView: TView, lView: LView, tNode: TDirectiveHostNode, native: RNode) {
|
||||||
const start = tNode.directiveStart;
|
const start = tNode.directiveStart;
|
||||||
const end = tNode.directiveEnd;
|
const end = tNode.directiveEnd;
|
||||||
if (!tView.firstTemplatePass) {
|
if (!tView.firstCreatePass) {
|
||||||
getOrCreateNodeInjectorForNode(tNode, lView);
|
getOrCreateNodeInjectorForNode(tNode, lView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,7 +1139,7 @@ function invokeDirectivesHostBindings(tView: TView, viewData: LView, tNode: TNod
|
||||||
const start = tNode.directiveStart;
|
const start = tNode.directiveStart;
|
||||||
const end = tNode.directiveEnd;
|
const end = tNode.directiveEnd;
|
||||||
const expando = tView.expandoInstructions !;
|
const expando = tView.expandoInstructions !;
|
||||||
const firstTemplatePass = tView.firstTemplatePass;
|
const firstCreatePass = tView.firstCreatePass;
|
||||||
const elementIndex = tNode.index - HEADER_OFFSET;
|
const elementIndex = tNode.index - HEADER_OFFSET;
|
||||||
try {
|
try {
|
||||||
setActiveHostElement(elementIndex);
|
setActiveHostElement(elementIndex);
|
||||||
|
@ -1151,8 +1151,8 @@ function invokeDirectivesHostBindings(tView: TView, viewData: LView, tNode: TNod
|
||||||
// It is important that this be called first before the actual instructions
|
// It is important that this be called first before the actual instructions
|
||||||
// are run because this way the first directive ID value is not zero.
|
// are run because this way the first directive ID value is not zero.
|
||||||
incrementActiveDirectiveId();
|
incrementActiveDirectiveId();
|
||||||
invokeHostBindingsInCreationMode(def, expando, directive, tNode, firstTemplatePass);
|
invokeHostBindingsInCreationMode(def, expando, directive, tNode, firstCreatePass);
|
||||||
} else if (firstTemplatePass) {
|
} else if (firstCreatePass) {
|
||||||
expando.push(null);
|
expando.push(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1163,7 @@ function invokeDirectivesHostBindings(tView: TView, viewData: LView, tNode: TNod
|
||||||
|
|
||||||
export function invokeHostBindingsInCreationMode(
|
export function invokeHostBindingsInCreationMode(
|
||||||
def: DirectiveDef<any>, expando: ExpandoInstructions, directive: any, tNode: TNode,
|
def: DirectiveDef<any>, expando: ExpandoInstructions, directive: any, tNode: TNode,
|
||||||
firstTemplatePass: boolean) {
|
firstCreatePass: boolean) {
|
||||||
const previousExpandoLength = expando.length;
|
const previousExpandoLength = expando.length;
|
||||||
setCurrentDirectiveDef(def);
|
setCurrentDirectiveDef(def);
|
||||||
const elementIndex = tNode.index - HEADER_OFFSET;
|
const elementIndex = tNode.index - HEADER_OFFSET;
|
||||||
|
@ -1173,7 +1173,7 @@ export function invokeHostBindingsInCreationMode(
|
||||||
// (e.g. it may not if it only contains host listeners), so we need to check whether
|
// (e.g. it may not if it only contains host listeners), so we need to check whether
|
||||||
// `expandoInstructions` has changed and if not - we still push `hostBindings` to
|
// `expandoInstructions` has changed and if not - we still push `hostBindings` to
|
||||||
// expando block, to make sure we execute it for DI cycle
|
// expando block, to make sure we execute it for DI cycle
|
||||||
if (previousExpandoLength === expando.length && firstTemplatePass) {
|
if (previousExpandoLength === expando.length && firstCreatePass) {
|
||||||
expando.push(def.hostBindings);
|
expando.push(def.hostBindings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1187,8 +1187,8 @@ export function invokeHostBindingsInCreationMode(
|
||||||
export function generateExpandoInstructionBlock(
|
export function generateExpandoInstructionBlock(
|
||||||
tView: TView, tNode: TNode, directiveCount: number): void {
|
tView: TView, tNode: TNode, directiveCount: number): void {
|
||||||
ngDevMode && assertEqual(
|
ngDevMode && assertEqual(
|
||||||
tView.firstTemplatePass, true,
|
tView.firstCreatePass, true,
|
||||||
'Expando block should only be generated on first template pass.');
|
'Expando block should only be generated on first create pass.');
|
||||||
|
|
||||||
const elementIndex = -(tNode.index - HEADER_OFFSET);
|
const elementIndex = -(tNode.index - HEADER_OFFSET);
|
||||||
const providerStartIndex = tNode.providerIndexes & TNodeProviderIndexes.ProvidersStartIndexMask;
|
const providerStartIndex = tNode.providerIndexes & TNodeProviderIndexes.ProvidersStartIndexMask;
|
||||||
|
@ -1204,7 +1204,7 @@ export function generateExpandoInstructionBlock(
|
||||||
function findDirectiveMatches(
|
function findDirectiveMatches(
|
||||||
tView: TView, viewData: LView,
|
tView: TView, viewData: LView,
|
||||||
tNode: TElementNode | TContainerNode | TElementContainerNode): DirectiveDef<any>[]|null {
|
tNode: TElementNode | TContainerNode | TElementContainerNode): DirectiveDef<any>[]|null {
|
||||||
ngDevMode && assertFirstTemplatePass(tView);
|
ngDevMode && assertFirstCreatePass(tView);
|
||||||
ngDevMode && assertNodeOfPossibleTypes(
|
ngDevMode && assertNodeOfPossibleTypes(
|
||||||
tNode, TNodeType.Element, TNodeType.ElementContainer, TNodeType.Container);
|
tNode, TNodeType.Element, TNodeType.ElementContainer, TNodeType.Container);
|
||||||
const registry = tView.directiveRegistry;
|
const registry = tView.directiveRegistry;
|
||||||
|
@ -1236,7 +1236,7 @@ function findDirectiveMatches(
|
||||||
* - storing index of component's host element so it will be queued for view refresh during CD.
|
* - storing index of component's host element so it will be queued for view refresh during CD.
|
||||||
*/
|
*/
|
||||||
export function markAsComponentHost(tView: TView, hostTNode: TNode): void {
|
export function markAsComponentHost(tView: TView, hostTNode: TNode): void {
|
||||||
ngDevMode && assertFirstTemplatePass(tView);
|
ngDevMode && assertFirstCreatePass(tView);
|
||||||
hostTNode.flags |= TNodeFlags.isComponentHost;
|
hostTNode.flags |= TNodeFlags.isComponentHost;
|
||||||
(tView.components || (tView.components = ngDevMode ? new TViewComponents() : [
|
(tView.components || (tView.components = ngDevMode ? new TViewComponents() : [
|
||||||
])).push(hostTNode.index);
|
])).push(hostTNode.index);
|
||||||
|
|
|
@ -360,10 +360,10 @@ export interface TView {
|
||||||
*/
|
*/
|
||||||
node: TViewNode|TElementNode|null;
|
node: TViewNode|TElementNode|null;
|
||||||
|
|
||||||
/** Whether or not this template has been processed. */
|
/** Whether or not this template has been processed in creation mode. */
|
||||||
firstTemplatePass: boolean;
|
firstCreatePass: boolean;
|
||||||
|
|
||||||
/** Whether or not the first update for this element has been processed. */
|
/** Whether or not the first update for this template has been processed. */
|
||||||
firstUpdatePass: boolean;
|
firstUpdatePass: boolean;
|
||||||
|
|
||||||
/** Static data equivalent of LView.data[]. Contains TNodes, PipeDefInternal or TI18n. */
|
/** Static data equivalent of LView.data[]. Contains TNodes, PipeDefInternal or TI18n. */
|
||||||
|
|
|
@ -34,7 +34,7 @@ export function ɵɵpipe(index: number, pipeName: string): any {
|
||||||
let pipeDef: PipeDef<any>;
|
let pipeDef: PipeDef<any>;
|
||||||
const adjustedIndex = index + HEADER_OFFSET;
|
const adjustedIndex = index + HEADER_OFFSET;
|
||||||
|
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
pipeDef = getPipeDef(pipeName, tView.pipeRegistry);
|
pipeDef = getPipeDef(pipeName, tView.pipeRegistry);
|
||||||
tView.data[adjustedIndex] = pipeDef;
|
tView.data[adjustedIndex] = pipeDef;
|
||||||
if (pipeDef.onDestroy) {
|
if (pipeDef.onDestroy) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {ViewContainerRef} from '../linker/view_container_ref';
|
||||||
import {assertDataInRange, assertDefined, throwError} from '../util/assert';
|
import {assertDataInRange, assertDefined, throwError} from '../util/assert';
|
||||||
import {stringify} from '../util/stringify';
|
import {stringify} from '../util/stringify';
|
||||||
|
|
||||||
import {assertFirstTemplatePass, assertLContainer} from './assert';
|
import {assertFirstCreatePass, assertLContainer} from './assert';
|
||||||
import {getNodeInjectable, locateDirectiveOrProvider} from './di';
|
import {getNodeInjectable, locateDirectiveOrProvider} from './di';
|
||||||
import {storeCleanupWithContext} from './instructions/shared';
|
import {storeCleanupWithContext} from './instructions/shared';
|
||||||
import {CONTAINER_HEADER_OFFSET, LContainer, MOVED_VIEWS} from './interfaces/container';
|
import {CONTAINER_HEADER_OFFSET, LContainer, MOVED_VIEWS} from './interfaces/container';
|
||||||
|
@ -89,7 +89,7 @@ class TQueries_ implements TQueries {
|
||||||
constructor(private queries: TQuery[] = []) {}
|
constructor(private queries: TQuery[] = []) {}
|
||||||
|
|
||||||
elementStart(tView: TView, tNode: TNode): void {
|
elementStart(tView: TView, tNode: TNode): void {
|
||||||
ngDevMode && assertFirstTemplatePass(
|
ngDevMode && assertFirstCreatePass(
|
||||||
tView, 'Queries should collect results on the first template pass only');
|
tView, 'Queries should collect results on the first template pass only');
|
||||||
for (let i = 0; i < this.queries.length; i++) {
|
for (let i = 0; i < this.queries.length; i++) {
|
||||||
this.queries[i].elementStart(tView, tNode);
|
this.queries[i].elementStart(tView, tNode);
|
||||||
|
@ -121,7 +121,7 @@ class TQueries_ implements TQueries {
|
||||||
}
|
}
|
||||||
|
|
||||||
template(tView: TView, tNode: TNode): void {
|
template(tView: TView, tNode: TNode): void {
|
||||||
ngDevMode && assertFirstTemplatePass(
|
ngDevMode && assertFirstCreatePass(
|
||||||
tView, 'Queries should collect results on the first template pass only');
|
tView, 'Queries should collect results on the first template pass only');
|
||||||
for (let i = 0; i < this.queries.length; i++) {
|
for (let i = 0; i < this.queries.length; i++) {
|
||||||
this.queries[i].template(tView, tNode);
|
this.queries[i].template(tView, tNode);
|
||||||
|
@ -439,7 +439,7 @@ function viewQueryInternal<T>(
|
||||||
lView: LView, predicate: Type<any>| string[], descend: boolean, read: any,
|
lView: LView, predicate: Type<any>| string[], descend: boolean, read: any,
|
||||||
isStatic: boolean): void {
|
isStatic: boolean): void {
|
||||||
const tView = lView[TVIEW];
|
const tView = lView[TVIEW];
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), -1);
|
createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), -1);
|
||||||
if (isStatic) {
|
if (isStatic) {
|
||||||
tView.staticViewQueries = true;
|
tView.staticViewQueries = true;
|
||||||
|
@ -488,7 +488,7 @@ function contentQueryInternal<T>(
|
||||||
lView: LView, predicate: Type<any>| string[], descend: boolean, read: any, isStatic: boolean,
|
lView: LView, predicate: Type<any>| string[], descend: boolean, read: any, isStatic: boolean,
|
||||||
tNode: TNode, directiveIndex: number): void {
|
tNode: TNode, directiveIndex: number): void {
|
||||||
const tView = lView[TVIEW];
|
const tView = lView[TVIEW];
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstCreatePass) {
|
||||||
createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), tNode.index);
|
createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), tNode.index);
|
||||||
saveContentQueryAndDirectiveIndex(tView, directiveIndex);
|
saveContentQueryAndDirectiveIndex(tView, directiveIndex);
|
||||||
if (isStatic) {
|
if (isStatic) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ function updateBindingData(
|
||||||
const hostBindingsMode = isHostStylingActive(sourceIndex);
|
const hostBindingsMode = isHostStylingActive(sourceIndex);
|
||||||
if (!isContextLocked(context, hostBindingsMode)) {
|
if (!isContextLocked(context, hostBindingsMode)) {
|
||||||
// this will only happen during the first update pass of the
|
// this will only happen during the first update pass of the
|
||||||
// context. The reason why we can't use `tNode.firstTemplatePass`
|
// context. The reason why we can't use `tView.firstCreatePass`
|
||||||
// here is because its not guaranteed to be true when the first
|
// here is because its not guaranteed to be true when the first
|
||||||
// update pass is executed (remember that all styling instructions
|
// update pass is executed (remember that all styling instructions
|
||||||
// are run in the update phase, and, as a result, are no more
|
// are run in the update phase, and, as a result, are no more
|
||||||
|
|
|
@ -29,7 +29,7 @@ declare global {
|
||||||
const ngDevMode: null|NgDevModePerfCounters;
|
const ngDevMode: null|NgDevModePerfCounters;
|
||||||
interface NgDevModePerfCounters {
|
interface NgDevModePerfCounters {
|
||||||
namedConstructors: boolean;
|
namedConstructors: boolean;
|
||||||
firstTemplatePass: number;
|
firstCreatePass: number;
|
||||||
tNode: number;
|
tNode: number;
|
||||||
tView: number;
|
tView: number;
|
||||||
rendererCreateTextNode: number;
|
rendererCreateTextNode: number;
|
||||||
|
@ -69,7 +69,7 @@ export function ngDevModeResetPerfCounters(): NgDevModePerfCounters {
|
||||||
const locationString = typeof location !== 'undefined' ? location.toString() : '';
|
const locationString = typeof location !== 'undefined' ? location.toString() : '';
|
||||||
const newCounters: NgDevModePerfCounters = {
|
const newCounters: NgDevModePerfCounters = {
|
||||||
namedConstructors: locationString.indexOf('ngDevMode=namedConstructors') != -1,
|
namedConstructors: locationString.indexOf('ngDevMode=namedConstructors') != -1,
|
||||||
firstTemplatePass: 0,
|
firstCreatePass: 0,
|
||||||
tNode: 0,
|
tNode: 0,
|
||||||
tView: 0,
|
tView: 0,
|
||||||
rendererCreateTextNode: 0,
|
rendererCreateTextNode: 0,
|
||||||
|
|
|
@ -691,7 +691,7 @@ describe('JS control flow', () => {
|
||||||
let log: string[] = [];
|
let log: string[] = [];
|
||||||
|
|
||||||
// Intentionally duplicating the templates in test below so we are
|
// Intentionally duplicating the templates in test below so we are
|
||||||
// testing the behavior on firstTemplatePass for each of these tests
|
// testing the behavior on firstCreatePass for each of these tests
|
||||||
class Comp {
|
class Comp {
|
||||||
static ɵfac =
|
static ɵfac =
|
||||||
() => {
|
() => {
|
||||||
|
@ -761,7 +761,7 @@ describe('JS control flow', () => {
|
||||||
let log: string[] = [];
|
let log: string[] = [];
|
||||||
|
|
||||||
// Intentionally duplicating the templates from above so we are
|
// Intentionally duplicating the templates from above so we are
|
||||||
// testing the behavior on firstTemplatePass for each of these tests
|
// testing the behavior on firstCreatePass for each of these tests
|
||||||
class Comp {
|
class Comp {
|
||||||
static ɵfac =
|
static ɵfac =
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -145,7 +145,7 @@ describe('di', () => {
|
||||||
describe('bloom filter', () => {
|
describe('bloom filter', () => {
|
||||||
let mockTView: any;
|
let mockTView: any;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockTView = {data: [0, 0, 0, 0, 0, 0, 0, 0, null], firstTemplatePass: true};
|
mockTView = {data: [0, 0, 0, 0, 0, 0, 0, 0, null], firstCreatePass: true};
|
||||||
});
|
});
|
||||||
|
|
||||||
function bloomState() { return mockTView.data.slice(0, TNODE).reverse(); }
|
function bloomState() { return mockTView.data.slice(0, TNODE).reverse(); }
|
||||||
|
|
|
@ -45,7 +45,7 @@ describe('instructions', () => {
|
||||||
t.update(() => { ɵɵproperty('title', 'World'); });
|
t.update(() => { ɵɵproperty('title', 'World'); });
|
||||||
expect(t.html).toEqual('<a title="World"></a>');
|
expect(t.html).toEqual('<a title="World"></a>');
|
||||||
expect(ngDevMode).toHaveProperties({
|
expect(ngDevMode).toHaveProperties({
|
||||||
firstTemplatePass: 1,
|
firstCreatePass: 1,
|
||||||
tNode: 2, // 1 for hostElement + 1 for the template under test
|
tNode: 2, // 1 for hostElement + 1 for the template under test
|
||||||
tView: 2, // 1 for rootView + 1 for the template view
|
tView: 2, // 1 for rootView + 1 for the template view
|
||||||
rendererCreateElement: 1,
|
rendererCreateElement: 1,
|
||||||
|
@ -64,7 +64,7 @@ describe('instructions', () => {
|
||||||
t.update();
|
t.update();
|
||||||
expect(t.html).toEqual('<a title="Hello"></a>');
|
expect(t.html).toEqual('<a title="Hello"></a>');
|
||||||
expect(ngDevMode).toHaveProperties({
|
expect(ngDevMode).toHaveProperties({
|
||||||
firstTemplatePass: 1,
|
firstCreatePass: 1,
|
||||||
tNode: 2, // 1 for hostElement + 1 for the template under test
|
tNode: 2, // 1 for hostElement + 1 for the template under test
|
||||||
tView: 2, // 1 for rootView + 1 for the template view
|
tView: 2, // 1 for rootView + 1 for the template view
|
||||||
rendererCreateElement: 1,
|
rendererCreateElement: 1,
|
||||||
|
@ -83,7 +83,7 @@ describe('instructions', () => {
|
||||||
expect(div.id).toEqual('test');
|
expect(div.id).toEqual('test');
|
||||||
expect(div.title).toEqual('Hello');
|
expect(div.title).toEqual('Hello');
|
||||||
expect(ngDevMode).toHaveProperties({
|
expect(ngDevMode).toHaveProperties({
|
||||||
firstTemplatePass: 1,
|
firstCreatePass: 1,
|
||||||
tNode: 2, // 1 for div, 1 for host element
|
tNode: 2, // 1 for div, 1 for host element
|
||||||
tView: 2, // 1 for rootView + 1 for the template view
|
tView: 2, // 1 for rootView + 1 for the template view
|
||||||
rendererCreateElement: 1,
|
rendererCreateElement: 1,
|
||||||
|
@ -103,7 +103,7 @@ describe('instructions', () => {
|
||||||
});
|
});
|
||||||
expect(t.html).toEqual('<div title="javascript:true"></div>');
|
expect(t.html).toEqual('<div title="javascript:true"></div>');
|
||||||
expect(ngDevMode).toHaveProperties({
|
expect(ngDevMode).toHaveProperties({
|
||||||
firstTemplatePass: 1,
|
firstCreatePass: 1,
|
||||||
tNode: 2, // 1 for div, 1 for host element
|
tNode: 2, // 1 for div, 1 for host element
|
||||||
tView: 2, // 1 for rootView + 1 for the template view
|
tView: 2, // 1 for rootView + 1 for the template view
|
||||||
rendererCreateElement: 1,
|
rendererCreateElement: 1,
|
||||||
|
@ -126,7 +126,7 @@ describe('instructions', () => {
|
||||||
t.update(() => { ɵɵproperty('title', 'two')('accessKey', 'B'); });
|
t.update(() => { ɵɵproperty('title', 'two')('accessKey', 'B'); });
|
||||||
expect(t.html).toEqual('<div accesskey="B" title="two"></div>');
|
expect(t.html).toEqual('<div accesskey="B" title="two"></div>');
|
||||||
expect(ngDevMode).toHaveProperties({
|
expect(ngDevMode).toHaveProperties({
|
||||||
firstTemplatePass: 1,
|
firstCreatePass: 1,
|
||||||
tNode: 2, // 1 for div, 1 for host element
|
tNode: 2, // 1 for div, 1 for host element
|
||||||
tView: 2, // 1 for rootView + 1 for the template view
|
tView: 2, // 1 for rootView + 1 for the template view
|
||||||
rendererCreateElement: 1,
|
rendererCreateElement: 1,
|
||||||
|
|
|
@ -34,7 +34,7 @@ describe('render3 integration test', () => {
|
||||||
expect(renderToHtml(Template, 'once', 1, 1)).toEqual('once');
|
expect(renderToHtml(Template, 'once', 1, 1)).toEqual('once');
|
||||||
expect(renderToHtml(Template, 'twice', 1, 1)).toEqual('once');
|
expect(renderToHtml(Template, 'twice', 1, 1)).toEqual('once');
|
||||||
expect(ngDevMode).toHaveProperties({
|
expect(ngDevMode).toHaveProperties({
|
||||||
firstTemplatePass: 0,
|
firstCreatePass: 0,
|
||||||
tNode: 2,
|
tNode: 2,
|
||||||
tView: 2, // 1 for root view, 1 for template
|
tView: 2, // 1 for root view, 1 for template
|
||||||
rendererSetText: 1,
|
rendererSetText: 1,
|
||||||
|
|
|
@ -240,7 +240,7 @@
|
||||||
creationMode);
|
creationMode);
|
||||||
currentView.creationMode = !1;
|
currentView.creationMode = !1;
|
||||||
currentView.lifecycleStage = 1;
|
currentView.lifecycleStage = 1;
|
||||||
currentView.tView.firstTemplatePass = !1;
|
currentView.tView.firstCreatePass = !1;
|
||||||
enterView(newView, null);
|
enterView(newView, null);
|
||||||
}
|
}
|
||||||
function createLView(viewId, renderer, tView, template, context) {
|
function createLView(viewId, renderer, tView, template, context) {
|
||||||
|
@ -360,7 +360,7 @@
|
||||||
function createTView() {
|
function createTView() {
|
||||||
return {
|
return {
|
||||||
data: [],
|
data: [],
|
||||||
firstTemplatePass: !0,
|
firstCreatePass: !0,
|
||||||
initHooks: null,
|
initHooks: null,
|
||||||
checkHooks: null,
|
checkHooks: null,
|
||||||
contentHooks: null,
|
contentHooks: null,
|
||||||
|
@ -511,7 +511,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
function(index, onInit, doCheck, tView) {
|
function(index, onInit, doCheck, tView) {
|
||||||
if (!0 === tView.firstTemplatePass) {
|
if (!0 === tView.firstCreatePass) {
|
||||||
null != onInit && (tView.initHooks || (tView.initHooks = [])).push(1, onInit);
|
null != onInit && (tView.initHooks || (tView.initHooks = [])).push(1, onInit);
|
||||||
if (null != doCheck) {
|
if (null != doCheck) {
|
||||||
(tView.initHooks || (tView.initHooks = [])).push(1, doCheck);
|
(tView.initHooks || (tView.initHooks = [])).push(1, doCheck);
|
||||||
|
|
Loading…
Reference in New Issue