From 66f269c077590365aa920cba8f0c48844f663695 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Tue, 21 May 2019 12:15:38 +0200 Subject: [PATCH] refactor(ivy): rename query-related functions for clarity (#30587) PR Close #30587 --- packages/core/src/render3/query.ts | 16 +++++++++------- packages/core/test/render3/query_spec.ts | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/core/src/render3/query.ts b/packages/core/src/render3/query.ts index 1b2daecea4..e768e40f7c 100644 --- a/packages/core/src/render3/query.ts +++ b/packages/core/src/render3/query.ts @@ -97,9 +97,9 @@ export class LQueries_ implements LQueries { track(queryList: QueryList, predicate: Type|string[], descend?: boolean, read?: Type): void { if (descend) { - this.deep = createQuery(this.deep, queryList, predicate, read != null ? read : null); + this.deep = createLQuery(this.deep, queryList, predicate, read != null ? read : null); } else { - this.shallow = createQuery(this.shallow, queryList, predicate, read != null ? read : null); + this.shallow = createLQuery(this.shallow, queryList, predicate, read != null ? read : null); } } @@ -346,7 +346,7 @@ function createPredicate(predicate: Type| string[], read: Type| null): }; } -function createQuery( +function createLQuery( previous: LQuery| null, queryList: QueryList, predicate: Type| string[], read: Type| null): LQuery { return { @@ -361,14 +361,14 @@ function createQuery( type QueryList_ = QueryList& {_valuesTree: any[], _static: boolean}; /** - * Creates and returns a QueryList. + * Creates a QueryList and stores it in LView's collection of active queries (LQueries). * * @param predicate The type for which the query will search * @param descend Whether or not to descend into children * @param read What to save in the query * @returns QueryList */ -function query( +function createQueryListInLView( // TODO: "read" should be an AbstractType (FW-486) lView: LView, predicate: Type| string[], descend: boolean, read: any, isStatic: boolean): QueryList { @@ -447,7 +447,8 @@ function viewQueryInternal( tView.expandoStartIndex++; } const index = getCurrentQueryIndex(); - const queryList: QueryList = query(lView, predicate, descend, read, isStatic); + const queryList: QueryList = + createQueryListInLView(lView, predicate, descend, read, isStatic); store(index - HEADER_OFFSET, queryList); setCurrentQueryIndex(index + 1); return queryList; @@ -490,7 +491,8 @@ function contentQueryInternal( descend: boolean, // TODO(FW-486): "read" should be an AbstractType read: any, isStatic: boolean): QueryList { - const contentQuery: QueryList = query(lView, predicate, descend, read, isStatic); + const contentQuery: QueryList = + createQueryListInLView(lView, predicate, descend, read, isStatic); (lView[CONTENT_QUERIES] || (lView[CONTENT_QUERIES] = [])).push(contentQuery); if (tView.firstTemplatePass) { const tViewContentQueries = tView.contentQueries || (tView.contentQueries = []); diff --git a/packages/core/test/render3/query_spec.ts b/packages/core/test/render3/query_spec.ts index bc54502ab9..935bca6a50 100644 --- a/packages/core/test/render3/query_spec.ts +++ b/packages/core/test/render3/query_spec.ts @@ -12,7 +12,7 @@ import {EventEmitter} from '../..'; import {AttributeMarker, detectChanges, ɵɵProvidersFeature, ɵɵdefineComponent, ɵɵdefineDirective} from '../../src/render3/index'; import {ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵdirectiveInject, ɵɵelement, ɵɵelementContainerEnd, ɵɵelementContainerStart, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵload, ɵɵtemplate, ɵɵtext} from '../../src/render3/instructions/all'; import {RenderFlags} from '../../src/render3/interfaces/definition'; -import {query, ɵɵcontentQuery, ɵɵloadContentQuery, ɵɵloadViewQuery, ɵɵqueryRefresh, ɵɵviewQuery} from '../../src/render3/query'; +import {ɵɵcontentQuery, ɵɵloadContentQuery, ɵɵloadViewQuery, ɵɵqueryRefresh, ɵɵviewQuery} from '../../src/render3/query'; import {getLView} from '../../src/render3/state'; import {getNativeByIndex} from '../../src/render3/util/view_utils'; import {ɵɵtemplateRefExtractor} from '../../src/render3/view_engine_compatibility_prebound';