diff --git a/packages/core/src/render3/PERF_NOTES.md b/packages/core/src/render3/PERF_NOTES.md index d2015a4d24..6d7b902e73 100644 --- a/packages/core/src/render3/PERF_NOTES.md +++ b/packages/core/src/render3/PERF_NOTES.md @@ -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 { 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. } } ``` -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. Simple refactoring will fix it. ``` export function i18nStart(index: number, message: string, subTemplateIndex?: number): void { const tView = getTView(); - if (tView.firstTemplatePass && tView.data[index + HEADER_OFFSET] === null) { - i18nStartFirstTemplatePass(tView, index, message, subTemplateIndex) + if (tView.firstCreatePass && tView.data[index + HEADER_OFFSET] === null) { + 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. } ``` diff --git a/packages/core/src/render3/assert.ts b/packages/core/src/render3/assert.ts index 1610c1253e..4415935875 100644 --- a/packages/core/src/render3/assert.ts +++ b/packages/core/src/render3/assert.ts @@ -68,7 +68,7 @@ export function assertLView(value: any) { assertEqual(isLView(value), true, 'Expecting LView'); } -export function assertFirstTemplatePass(tView: TView, errMessage?: string) { +export function assertFirstCreatePass(tView: TView, errMessage?: string) { 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.'); } diff --git a/packages/core/src/render3/component.ts b/packages/core/src/render3/component.ts index 7884bbc34c..58e5491c75 100644 --- a/packages/core/src/render3/component.ts +++ b/packages/core/src/render3/component.ts @@ -174,7 +174,7 @@ export function createRootComponentView( rootView, getOrCreateTView(def), null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways, rootView[HEADER_OFFSET], tNode, rendererFactory, renderer, sanitizer); - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type); markAsComponentHost(tView, tNode); initNodeFlags(tNode, rootView.length, 1); @@ -209,14 +209,14 @@ export function createRootComponent( } const rootTNode = getPreviousOrParentTNode(); - if (tView.firstTemplatePass && componentDef.hostBindings) { + if (tView.firstCreatePass && componentDef.hostBindings) { const elementIndex = rootTNode.index - HEADER_OFFSET; setActiveHostElement(elementIndex); incrementActiveDirectiveId(); const expando = tView.expandoInstructions !; invokeHostBindingsInCreationMode( - componentDef, expando, component, rootTNode, tView.firstTemplatePass); + componentDef, expando, component, rootTNode, tView.firstCreatePass); setActiveHostElement(null); } diff --git a/packages/core/src/render3/di.ts b/packages/core/src/render3/di.ts index a095dc47f5..03078b8c52 100644 --- a/packages/core/src/render3/di.ts +++ b/packages/core/src/render3/di.ts @@ -97,7 +97,7 @@ let nextNgElementId = 0; */ export function bloomAdd( injectorIndex: number, tView: TView, type: Type| InjectionToken| 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 = typeof type !== 'string' ? (type as any)[NG_ELEMENT_ID] : type.charCodeAt(0) || 0; @@ -147,7 +147,7 @@ export function getOrCreateNodeInjectorForNode( } const tView = hostView[TVIEW]; - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { tNode.injectorIndex = hostView.length; insertBloom(tView.data, tNode); // foundation for node bloom insertBloom(hostView, null); // foundation for cumulative bloom diff --git a/packages/core/src/render3/di_setup.ts b/packages/core/src/render3/di_setup.ts index 9716a70fa1..f400d40ecc 100644 --- a/packages/core/src/render3/di_setup.ts +++ b/packages/core/src/render3/di_setup.ts @@ -44,7 +44,7 @@ export function providersResolver( def: DirectiveDef, providers: Provider[], viewProviders: Provider[]): void { const lView = getLView(); const tView: TView = lView[TVIEW]; - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { const isComponent = isComponentDef(def); // The list of view providers is processed first, and the flags are updated diff --git a/packages/core/src/render3/hooks.ts b/packages/core/src/render3/hooks.ts index 4c7c564118..8bedf39135 100644 --- a/packages/core/src/render3/hooks.ts +++ b/packages/core/src/render3/hooks.ts @@ -8,7 +8,7 @@ import {assertEqual, assertNotEqual} from '../util/assert'; -import {assertFirstTemplatePass} from './assert'; +import {assertFirstCreatePass} from './assert'; import {DirectiveDef} from './interfaces/definition'; import {TNode} from './interfaces/node'; 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( directiveIndex: number, directiveDef: DirectiveDef, tView: TView, nodeIndex: number, initialPreOrderHooksLength: number, initialPreOrderCheckHooksLength: number): void { - ngDevMode && assertFirstTemplatePass(tView); + ngDevMode && assertFirstCreatePass(tView); const {onChanges, onInit, doCheck} = directiveDef; if (initialPreOrderHooksLength >= 0 && (!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 */ 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 // 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. diff --git a/packages/core/src/render3/i18n.ts b/packages/core/src/render3/i18n.ts index 09c8a5f745..cce8dc5243 100644 --- a/packages/core/src/render3/i18n.ts +++ b/packages/core/src/render3/i18n.ts @@ -366,7 +366,7 @@ export function ɵɵi18nStart(index: number, message: string, subTemplateIndex?: i18nIndexStack[++i18nIndexStackPointer] = index; // We need to delay projections until `i18nEnd` 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); } } @@ -1006,7 +1006,7 @@ function i18nAttributesFirstPass(lView: LView, tView: TView, index: number, valu // Even indexes are text (including bindings) const hasBinding = !!value.match(BINDING_REGEXP); if (hasBinding) { - if (tView.firstTemplatePass && tView.data[index + HEADER_OFFSET] === null) { + if (tView.firstCreatePass && tView.data[index + HEADER_OFFSET] === null) { addAllToArray( 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; } } diff --git a/packages/core/src/render3/instructions/alloc_host_vars.ts b/packages/core/src/render3/instructions/alloc_host_vars.ts index 7301c9726f..1e4c22ccff 100644 --- a/packages/core/src/render3/instructions/alloc_host_vars.ts +++ b/packages/core/src/render3/instructions/alloc_host_vars.ts @@ -22,7 +22,7 @@ import {NO_CHANGE} from '../tokens'; export function ɵɵallocHostVars(count: number): void { const lView = getLView(); const tView = lView[TVIEW]; - if (!tView.firstTemplatePass) return; + if (!tView.firstCreatePass) return; queueHostBindingForCheck(tView, getCurrentDirectiveDef() !, count); prefillHostVars(tView, lView, count); } @@ -34,7 +34,7 @@ export function ɵɵallocHostVars(count: number): void { function queueHostBindingForCheck( tView: TView, def: DirectiveDef| ComponentDef, hostVars: number): void { 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 length = expando.length; // 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 { 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++) { lView.push(NO_CHANGE); tView.blueprint.push(NO_CHANGE); diff --git a/packages/core/src/render3/instructions/container.ts b/packages/core/src/render3/instructions/container.ts index 90b02b18f0..7cf718e86d 100644 --- a/packages/core/src/render3/instructions/container.ts +++ b/packages/core/src/render3/instructions/container.ts @@ -38,7 +38,7 @@ export function ɵɵcontainer(index: number): void { const lView = getLView(); const tNode = containerInternal(lView, index, null, null); - if (lView[TVIEW].firstTemplatePass) { + if (lView[TVIEW].firstCreatePass) { tNode.tViews = []; } setIsNotParent(); @@ -75,8 +75,8 @@ export function ɵɵtemplate( const tContainerNode = containerInternal( lView, index, tagName || null, getConstant(tViewConsts, attrsIndex) as TAttributes); const localRefs = getConstant(tViewConsts, localRefsIndex) as string[]; - if (tView.firstTemplatePass) { - ngDevMode && ngDevMode.firstTemplatePass++; + if (tView.firstCreatePass) { + ngDevMode && ngDevMode.firstCreatePass++; resolveDirectives(tView, lView, tContainerNode, localRefs); registerPostOrderHooks(tView, tContainerNode); diff --git a/packages/core/src/render3/instructions/element.ts b/packages/core/src/render3/instructions/element.ts index 735bd14677..14b31cea00 100644 --- a/packages/core/src/render3/instructions/element.ts +++ b/packages/core/src/render3/instructions/element.ts @@ -59,7 +59,7 @@ export function ɵɵelementStart( if (attrs != null) { const lastAttrIndex = setUpAttributes(renderer, native, attrs); - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex); } } @@ -82,8 +82,8 @@ export function ɵɵelementStart( // 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]` // and `[class]` bindings work for multiple directives.) - if (tView.firstTemplatePass) { - ngDevMode && ngDevMode.firstTemplatePass++; + if (tView.firstCreatePass) { + ngDevMode && ngDevMode.firstCreatePass++; const hasDirectives = resolveDirectives(tView, lView, tNode, localRefs); ngDevMode && validateElement(lView, native, tNode, hasDirectives); @@ -125,7 +125,7 @@ export function ɵɵelementEnd(): void { decreaseElementDepthCount(); - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { registerPostOrderHooks(tView, previousOrParentTNode); if (isContentQueryHost(previousOrParentTNode)) { tView.queries !.elementEnd(previousOrParentTNode); @@ -210,7 +210,7 @@ export function ɵɵelementHostAttrs(attrs: TAttributes) { if (tNode.type === TNodeType.Element) { const native = getNativeByTNode(tNode, lView) as RElement; const lastAttrIndex = setUpAttributes(lView[RENDERER], native, attrs); - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { const stylingNeedsToBeRendered = registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex); // this is only called during the first template pass in the diff --git a/packages/core/src/render3/instructions/element_container.ts b/packages/core/src/render3/instructions/element_container.ts index 10f6b3cc6f..47565f7c51 100644 --- a/packages/core/src/render3/instructions/element_container.ts +++ b/packages/core/src/render3/instructions/element_container.ts @@ -57,7 +57,7 @@ export function ɵɵelementContainerStart( const tNode = 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 // and execute directives on the ng-container. registerInitialStylingOnTNode(tNode, attrs, 0); @@ -66,8 +66,8 @@ export function ɵɵelementContainerStart( appendChild(native, tNode, lView); attachPatchData(native, lView); - if (tView.firstTemplatePass) { - ngDevMode && ngDevMode.firstTemplatePass++; + if (tView.firstCreatePass) { + ngDevMode && ngDevMode.firstCreatePass++; resolveDirectives(tView, lView, tNode, localRefs); if (tView.queries) { tView.queries.elementStart(tView, tNode); @@ -103,7 +103,7 @@ export function ɵɵelementContainerEnd(): void { ngDevMode && assertNodeType(previousOrParentTNode, TNodeType.ElementContainer); - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { registerPostOrderHooks(tView, previousOrParentTNode); if (isContentQueryHost(previousOrParentTNode)) { tView.queries !.elementEnd(previousOrParentTNode); diff --git a/packages/core/src/render3/instructions/listener.ts b/packages/core/src/render3/instructions/listener.ts index 307423c46c..9f164d5715 100644 --- a/packages/core/src/render3/instructions/listener.ts +++ b/packages/core/src/render3/instructions/listener.ts @@ -114,8 +114,8 @@ function listenerInternal( eventTargetResolver?: GlobalTargetResolver): void { const tView = lView[TVIEW]; const isTNodeDirectiveHost = isDirectiveHost(tNode); - const firstTemplatePass = tView.firstTemplatePass; - const tCleanup: false|any[] = firstTemplatePass && (tView.cleanup || (tView.cleanup = [])); + const firstCreatePass = tView.firstCreatePass; + const tCleanup: false|any[] = firstCreatePass && (tView.cleanup || (tView.cleanup = [])); ngDevMode && assertNodeOfPossibleTypes( tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer); diff --git a/packages/core/src/render3/instructions/lview_debug.ts b/packages/core/src/render3/instructions/lview_debug.ts index a6863b55db..1a435c1e9e 100644 --- a/packages/core/src/render3/instructions/lview_debug.ts +++ b/packages/core/src/render3/instructions/lview_debug.ts @@ -85,7 +85,7 @@ export const TViewConstructor = class TView implements ITView { public bindingStartIndex: number, // public expandoStartIndex: number, // public expandoInstructions: ExpandoInstructions|null, // - public firstTemplatePass: boolean, // + public firstCreatePass: boolean, // public firstUpdatePass: boolean, // public staticViewQueries: boolean, // public staticContentQueries: boolean, // diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index 39ceddc989..6247a3ccd1 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -14,7 +14,7 @@ import {assertDataInRange, assertDefined, assertDomNode, assertEqual, assertGrea import {createNamedArrayType} from '../../util/named_array_type'; import {initNgDevMode} from '../../util/ng_dev_mode'; import {normalizeDebugBindingName, normalizeDebugBindingValue} from '../../util/ng_reflect'; -import {assertFirstTemplatePass, assertLView} from '../assert'; +import {assertFirstCreatePass, assertLView} from '../assert'; import {attachPatchData} from '../context_discovery'; import {getFactoryDef} from '../definition'; 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'); if (numSlotsToAlloc > 0) { const tView = view[TVIEW]; - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { for (let i = 0; i < numSlotsToAlloc; i++) { tView.blueprint.push(null); tView.data.push(null); @@ -330,10 +330,10 @@ export function renderView(lView: LView, tView: TView, context: T): void { // 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 // 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. - if (tView.firstTemplatePass) { - tView.firstTemplatePass = false; + if (tView.firstCreatePass) { + tView.firstCreatePass = false; } // We resolve content queries specifically marked as `static` in creation mode. Dynamic @@ -611,7 +611,7 @@ export function createTView( bindingStartIndex, // bindingStartIndex: number, initialViewLength, // expandoStartIndex: number, null, // expandoInstructions: ExpandoInstructions|null, - true, // firstTemplatePass: boolean, + true, // firstCreatePass: boolean, true, // firstUpdatePass: boolean, false, // staticViewQueries: boolean, false, // staticContentQueries: boolean, @@ -643,7 +643,7 @@ export function createTView( bindingStartIndex: bindingStartIndex, expandoStartIndex: initialViewLength, expandoInstructions: null, - firstTemplatePass: true, + firstCreatePass: true, firstUpdatePass: true, staticViewQueries: false, staticContentQueries: false, @@ -714,7 +714,7 @@ export function storeCleanupWithContext(lView: LView, context: any, cleanupFn: F const lCleanup = getCleanup(lView); lCleanup.push(context); - if (lView[TVIEW].firstTemplatePass) { + if (lView[TVIEW].firstCreatePass) { 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 { getCleanup(view).push(cleanupFn); - if (view[TVIEW].firstTemplatePass) { + if (view[TVIEW].firstCreatePass) { 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. */ function initializeInputAndOutputAliases(tView: TView, tNode: TNode): void { - ngDevMode && assertFirstTemplatePass(tView); + ngDevMode && assertFirstCreatePass(tView); const start = tNode.directiveStart; const end = tNode.directiveEnd; @@ -1025,7 +1025,7 @@ function warnAboutUnknownProperty(propName: string, tNode: TNode): void { */ export function instantiateRootComponent(tView: TView, lView: LView, def: ComponentDef): T { const rootTNode = getPreviousOrParentTNode(); - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { if (def.providersResolver) def.providersResolver(def); generateExpandoInstructionBlock(tView, rootTNode, 1); baseResolveDirective(tView, lView, def); @@ -1048,7 +1048,7 @@ export function resolveDirectives( localRefs: string[] | null): boolean { // Please make sure to have explicit type for `exportsMap`. Inferred type triggers bug in // tsickle. - ngDevMode && assertFirstTemplatePass(tView); + ngDevMode && assertFirstCreatePass(tView); if (!getBindingsEnabled()) return false; @@ -1105,7 +1105,7 @@ function instantiateAllDirectives( tView: TView, lView: LView, tNode: TDirectiveHostNode, native: RNode) { const start = tNode.directiveStart; const end = tNode.directiveEnd; - if (!tView.firstTemplatePass) { + if (!tView.firstCreatePass) { getOrCreateNodeInjectorForNode(tNode, lView); } @@ -1139,7 +1139,7 @@ function invokeDirectivesHostBindings(tView: TView, viewData: LView, tNode: TNod const start = tNode.directiveStart; const end = tNode.directiveEnd; const expando = tView.expandoInstructions !; - const firstTemplatePass = tView.firstTemplatePass; + const firstCreatePass = tView.firstCreatePass; const elementIndex = tNode.index - HEADER_OFFSET; try { 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 // are run because this way the first directive ID value is not zero. incrementActiveDirectiveId(); - invokeHostBindingsInCreationMode(def, expando, directive, tNode, firstTemplatePass); - } else if (firstTemplatePass) { + invokeHostBindingsInCreationMode(def, expando, directive, tNode, firstCreatePass); + } else if (firstCreatePass) { expando.push(null); } } @@ -1163,7 +1163,7 @@ function invokeDirectivesHostBindings(tView: TView, viewData: LView, tNode: TNod export function invokeHostBindingsInCreationMode( def: DirectiveDef, expando: ExpandoInstructions, directive: any, tNode: TNode, - firstTemplatePass: boolean) { + firstCreatePass: boolean) { const previousExpandoLength = expando.length; setCurrentDirectiveDef(def); 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 // `expandoInstructions` has changed and if not - we still push `hostBindings` to // 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); } } @@ -1187,8 +1187,8 @@ export function invokeHostBindingsInCreationMode( export function generateExpandoInstructionBlock( tView: TView, tNode: TNode, directiveCount: number): void { ngDevMode && assertEqual( - tView.firstTemplatePass, true, - 'Expando block should only be generated on first template pass.'); + tView.firstCreatePass, true, + 'Expando block should only be generated on first create pass.'); const elementIndex = -(tNode.index - HEADER_OFFSET); const providerStartIndex = tNode.providerIndexes & TNodeProviderIndexes.ProvidersStartIndexMask; @@ -1204,7 +1204,7 @@ export function generateExpandoInstructionBlock( function findDirectiveMatches( tView: TView, viewData: LView, tNode: TElementNode | TContainerNode | TElementContainerNode): DirectiveDef[]|null { - ngDevMode && assertFirstTemplatePass(tView); + ngDevMode && assertFirstCreatePass(tView); ngDevMode && assertNodeOfPossibleTypes( tNode, TNodeType.Element, TNodeType.ElementContainer, TNodeType.Container); 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. */ export function markAsComponentHost(tView: TView, hostTNode: TNode): void { - ngDevMode && assertFirstTemplatePass(tView); + ngDevMode && assertFirstCreatePass(tView); hostTNode.flags |= TNodeFlags.isComponentHost; (tView.components || (tView.components = ngDevMode ? new TViewComponents() : [ ])).push(hostTNode.index); diff --git a/packages/core/src/render3/interfaces/view.ts b/packages/core/src/render3/interfaces/view.ts index ff50bd1805..26ac3e4aac 100644 --- a/packages/core/src/render3/interfaces/view.ts +++ b/packages/core/src/render3/interfaces/view.ts @@ -360,10 +360,10 @@ export interface TView { */ node: TViewNode|TElementNode|null; - /** Whether or not this template has been processed. */ - firstTemplatePass: boolean; + /** Whether or not this template has been processed in creation mode. */ + 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; /** Static data equivalent of LView.data[]. Contains TNodes, PipeDefInternal or TI18n. */ diff --git a/packages/core/src/render3/pipe.ts b/packages/core/src/render3/pipe.ts index b741e393a9..aeb7019afa 100644 --- a/packages/core/src/render3/pipe.ts +++ b/packages/core/src/render3/pipe.ts @@ -34,7 +34,7 @@ export function ɵɵpipe(index: number, pipeName: string): any { let pipeDef: PipeDef; const adjustedIndex = index + HEADER_OFFSET; - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { pipeDef = getPipeDef(pipeName, tView.pipeRegistry); tView.data[adjustedIndex] = pipeDef; if (pipeDef.onDestroy) { diff --git a/packages/core/src/render3/query.ts b/packages/core/src/render3/query.ts index 452d47b1ac..b6d43f18a0 100644 --- a/packages/core/src/render3/query.ts +++ b/packages/core/src/render3/query.ts @@ -17,7 +17,7 @@ import {ViewContainerRef} from '../linker/view_container_ref'; import {assertDataInRange, assertDefined, throwError} from '../util/assert'; import {stringify} from '../util/stringify'; -import {assertFirstTemplatePass, assertLContainer} from './assert'; +import {assertFirstCreatePass, assertLContainer} from './assert'; import {getNodeInjectable, locateDirectiveOrProvider} from './di'; import {storeCleanupWithContext} from './instructions/shared'; import {CONTAINER_HEADER_OFFSET, LContainer, MOVED_VIEWS} from './interfaces/container'; @@ -89,7 +89,7 @@ class TQueries_ implements TQueries { constructor(private queries: TQuery[] = []) {} elementStart(tView: TView, tNode: TNode): void { - ngDevMode && assertFirstTemplatePass( + ngDevMode && assertFirstCreatePass( tView, 'Queries should collect results on the first template pass only'); for (let i = 0; i < this.queries.length; i++) { this.queries[i].elementStart(tView, tNode); @@ -121,7 +121,7 @@ class TQueries_ implements TQueries { } template(tView: TView, tNode: TNode): void { - ngDevMode && assertFirstTemplatePass( + ngDevMode && assertFirstCreatePass( tView, 'Queries should collect results on the first template pass only'); for (let i = 0; i < this.queries.length; i++) { this.queries[i].template(tView, tNode); @@ -439,7 +439,7 @@ function viewQueryInternal( lView: LView, predicate: Type| string[], descend: boolean, read: any, isStatic: boolean): void { const tView = lView[TVIEW]; - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), -1); if (isStatic) { tView.staticViewQueries = true; @@ -488,7 +488,7 @@ function contentQueryInternal( lView: LView, predicate: Type| string[], descend: boolean, read: any, isStatic: boolean, tNode: TNode, directiveIndex: number): void { const tView = lView[TVIEW]; - if (tView.firstTemplatePass) { + if (tView.firstCreatePass) { createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), tNode.index); saveContentQueryAndDirectiveIndex(tView, directiveIndex); if (isStatic) { diff --git a/packages/core/src/render3/styling/bindings.ts b/packages/core/src/render3/styling/bindings.ts index 149d26ad99..4d2ee44d3f 100644 --- a/packages/core/src/render3/styling/bindings.ts +++ b/packages/core/src/render3/styling/bindings.ts @@ -145,7 +145,7 @@ function updateBindingData( const hostBindingsMode = isHostStylingActive(sourceIndex); if (!isContextLocked(context, hostBindingsMode)) { // 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 // update pass is executed (remember that all styling instructions // are run in the update phase, and, as a result, are no more diff --git a/packages/core/src/util/ng_dev_mode.ts b/packages/core/src/util/ng_dev_mode.ts index eeee40f078..716ee46491 100644 --- a/packages/core/src/util/ng_dev_mode.ts +++ b/packages/core/src/util/ng_dev_mode.ts @@ -29,7 +29,7 @@ declare global { const ngDevMode: null|NgDevModePerfCounters; interface NgDevModePerfCounters { namedConstructors: boolean; - firstTemplatePass: number; + firstCreatePass: number; tNode: number; tView: number; rendererCreateTextNode: number; @@ -69,7 +69,7 @@ export function ngDevModeResetPerfCounters(): NgDevModePerfCounters { const locationString = typeof location !== 'undefined' ? location.toString() : ''; const newCounters: NgDevModePerfCounters = { namedConstructors: locationString.indexOf('ngDevMode=namedConstructors') != -1, - firstTemplatePass: 0, + firstCreatePass: 0, tNode: 0, tView: 0, rendererCreateTextNode: 0, diff --git a/packages/core/test/render3/control_flow_spec.ts b/packages/core/test/render3/control_flow_spec.ts index 0cd385a7b6..c401d42c9b 100644 --- a/packages/core/test/render3/control_flow_spec.ts +++ b/packages/core/test/render3/control_flow_spec.ts @@ -691,7 +691,7 @@ describe('JS control flow', () => { let log: string[] = []; // 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 { static ɵfac = () => { @@ -761,7 +761,7 @@ describe('JS control flow', () => { let log: string[] = []; // 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 { static ɵfac = () => { diff --git a/packages/core/test/render3/di_spec.ts b/packages/core/test/render3/di_spec.ts index ed372f4d84..bba9909f75 100644 --- a/packages/core/test/render3/di_spec.ts +++ b/packages/core/test/render3/di_spec.ts @@ -145,7 +145,7 @@ describe('di', () => { describe('bloom filter', () => { let mockTView: any; 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(); } diff --git a/packages/core/test/render3/instructions_spec.ts b/packages/core/test/render3/instructions_spec.ts index a33e2003cd..68cfff3b1e 100644 --- a/packages/core/test/render3/instructions_spec.ts +++ b/packages/core/test/render3/instructions_spec.ts @@ -45,7 +45,7 @@ describe('instructions', () => { t.update(() => { ɵɵproperty('title', 'World'); }); expect(t.html).toEqual(''); expect(ngDevMode).toHaveProperties({ - firstTemplatePass: 1, + firstCreatePass: 1, tNode: 2, // 1 for hostElement + 1 for the template under test tView: 2, // 1 for rootView + 1 for the template view rendererCreateElement: 1, @@ -64,7 +64,7 @@ describe('instructions', () => { t.update(); expect(t.html).toEqual(''); expect(ngDevMode).toHaveProperties({ - firstTemplatePass: 1, + firstCreatePass: 1, tNode: 2, // 1 for hostElement + 1 for the template under test tView: 2, // 1 for rootView + 1 for the template view rendererCreateElement: 1, @@ -83,7 +83,7 @@ describe('instructions', () => { expect(div.id).toEqual('test'); expect(div.title).toEqual('Hello'); expect(ngDevMode).toHaveProperties({ - firstTemplatePass: 1, + firstCreatePass: 1, tNode: 2, // 1 for div, 1 for host element tView: 2, // 1 for rootView + 1 for the template view rendererCreateElement: 1, @@ -103,7 +103,7 @@ describe('instructions', () => { }); expect(t.html).toEqual('
'); expect(ngDevMode).toHaveProperties({ - firstTemplatePass: 1, + firstCreatePass: 1, tNode: 2, // 1 for div, 1 for host element tView: 2, // 1 for rootView + 1 for the template view rendererCreateElement: 1, @@ -126,7 +126,7 @@ describe('instructions', () => { t.update(() => { ɵɵproperty('title', 'two')('accessKey', 'B'); }); expect(t.html).toEqual('
'); expect(ngDevMode).toHaveProperties({ - firstTemplatePass: 1, + firstCreatePass: 1, tNode: 2, // 1 for div, 1 for host element tView: 2, // 1 for rootView + 1 for the template view rendererCreateElement: 1, diff --git a/packages/core/test/render3/integration_spec.ts b/packages/core/test/render3/integration_spec.ts index 155fbc3cdf..041613ad86 100644 --- a/packages/core/test/render3/integration_spec.ts +++ b/packages/core/test/render3/integration_spec.ts @@ -34,7 +34,7 @@ describe('render3 integration test', () => { expect(renderToHtml(Template, 'once', 1, 1)).toEqual('once'); expect(renderToHtml(Template, 'twice', 1, 1)).toEqual('once'); expect(ngDevMode).toHaveProperties({ - firstTemplatePass: 0, + firstCreatePass: 0, tNode: 2, tView: 2, // 1 for root view, 1 for template rendererSetText: 1, diff --git a/tools/symbol-extractor/symbol_extractor_spec/hello_world_min_debug.js b/tools/symbol-extractor/symbol_extractor_spec/hello_world_min_debug.js index fad9a5d17f..840dc2e27c 100644 --- a/tools/symbol-extractor/symbol_extractor_spec/hello_world_min_debug.js +++ b/tools/symbol-extractor/symbol_extractor_spec/hello_world_min_debug.js @@ -240,7 +240,7 @@ creationMode); currentView.creationMode = !1; currentView.lifecycleStage = 1; - currentView.tView.firstTemplatePass = !1; + currentView.tView.firstCreatePass = !1; enterView(newView, null); } function createLView(viewId, renderer, tView, template, context) { @@ -360,7 +360,7 @@ function createTView() { return { data: [], - firstTemplatePass: !0, + firstCreatePass: !0, initHooks: null, checkHooks: null, contentHooks: null, @@ -511,7 +511,7 @@ * found in the LICENSE file at https://angular.io/license */ function(index, onInit, doCheck, tView) { - if (!0 === tView.firstTemplatePass) { + if (!0 === tView.firstCreatePass) { null != onInit && (tView.initHooks || (tView.initHooks = [])).push(1, onInit); if (null != doCheck) { (tView.initHooks || (tView.initHooks = [])).push(1, doCheck);