Skip to content

Commit 66f269c

Browse files
pkozlowski-opensourcejasonaden
authored andcommitted
refactor(ivy): rename query-related functions for clarity (angular#30587)
PR Close angular#30587
1 parent b613f90 commit 66f269c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/core/src/render3/query.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ export class LQueries_ implements LQueries {
9797
track<T>(queryList: QueryList<T>, predicate: Type<T>|string[], descend?: boolean, read?: Type<T>):
9898
void {
9999
if (descend) {
100-
this.deep = createQuery(this.deep, queryList, predicate, read != null ? read : null);
100+
this.deep = createLQuery(this.deep, queryList, predicate, read != null ? read : null);
101101
} else {
102-
this.shallow = createQuery(this.shallow, queryList, predicate, read != null ? read : null);
102+
this.shallow = createLQuery(this.shallow, queryList, predicate, read != null ? read : null);
103103
}
104104
}
105105

@@ -346,7 +346,7 @@ function createPredicate<T>(predicate: Type<T>| string[], read: Type<T>| null):
346346
};
347347
}
348348

349-
function createQuery<T>(
349+
function createLQuery<T>(
350350
previous: LQuery<any>| null, queryList: QueryList<T>, predicate: Type<T>| string[],
351351
read: Type<T>| null): LQuery<T> {
352352
return {
@@ -361,14 +361,14 @@ function createQuery<T>(
361361
type QueryList_<T> = QueryList<T>& {_valuesTree: any[], _static: boolean};
362362

363363
/**
364-
* Creates and returns a QueryList.
364+
* Creates a QueryList and stores it in LView's collection of active queries (LQueries).
365365
*
366366
* @param predicate The type for which the query will search
367367
* @param descend Whether or not to descend into children
368368
* @param read What to save in the query
369369
* @returns QueryList<T>
370370
*/
371-
function query<T>(
371+
function createQueryListInLView<T>(
372372
// TODO: "read" should be an AbstractType (FW-486)
373373
lView: LView, predicate: Type<any>| string[], descend: boolean, read: any,
374374
isStatic: boolean): QueryList<T> {
@@ -447,7 +447,8 @@ function viewQueryInternal<T>(
447447
tView.expandoStartIndex++;
448448
}
449449
const index = getCurrentQueryIndex();
450-
const queryList: QueryList<T> = query<T>(lView, predicate, descend, read, isStatic);
450+
const queryList: QueryList<T> =
451+
createQueryListInLView<T>(lView, predicate, descend, read, isStatic);
451452
store(index - HEADER_OFFSET, queryList);
452453
setCurrentQueryIndex(index + 1);
453454
return queryList;
@@ -490,7 +491,8 @@ function contentQueryInternal<T>(
490491
descend: boolean,
491492
// TODO(FW-486): "read" should be an AbstractType
492493
read: any, isStatic: boolean): QueryList<T> {
493-
const contentQuery: QueryList<T> = query<T>(lView, predicate, descend, read, isStatic);
494+
const contentQuery: QueryList<T> =
495+
createQueryListInLView<T>(lView, predicate, descend, read, isStatic);
494496
(lView[CONTENT_QUERIES] || (lView[CONTENT_QUERIES] = [])).push(contentQuery);
495497
if (tView.firstTemplatePass) {
496498
const tViewContentQueries = tView.contentQueries || (tView.contentQueries = []);

packages/core/test/render3/query_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {EventEmitter} from '../..';
1212
import {AttributeMarker, detectChanges, ɵɵProvidersFeature, ɵɵdefineComponent, ɵɵdefineDirective} from '../../src/render3/index';
1313
import {ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵdirectiveInject, ɵɵelement, ɵɵelementContainerEnd, ɵɵelementContainerStart, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵload, ɵɵtemplate, ɵɵtext} from '../../src/render3/instructions/all';
1414
import {RenderFlags} from '../../src/render3/interfaces/definition';
15-
import {query, ɵɵcontentQuery, ɵɵloadContentQuery, ɵɵloadViewQuery, ɵɵqueryRefresh, ɵɵviewQuery} from '../../src/render3/query';
15+
import {ɵɵcontentQuery, ɵɵloadContentQuery, ɵɵloadViewQuery, ɵɵqueryRefresh, ɵɵviewQuery} from '../../src/render3/query';
1616
import {getLView} from '../../src/render3/state';
1717
import {getNativeByIndex} from '../../src/render3/util/view_utils';
1818
import {ɵɵtemplateRefExtractor} from '../../src/render3/view_engine_compatibility_prebound';

0 commit comments

Comments
 (0)