diff --git a/packages/core/src/render3/query.ts b/packages/core/src/render3/query.ts index e768e40f7c..18a5bd4183 100644 --- a/packages/core/src/render3/query.ts +++ b/packages/core/src/render3/query.ts @@ -58,35 +58,35 @@ export interface QueryPredicate { * - values collected based on a predicate * - `QueryList` to which collected values should be reported */ -export interface LQuery { - /** - * Next query. Used when queries are stored as a linked list in `LQueries`. - */ - next: LQuery|null; +class LQuery { + constructor( + /** + * Next query. Used when queries are stored as a linked list in `LQueries`. + */ + public next: LQuery|null, - /** - * Destination to which the value should be added. - */ - list: QueryList; + /** + * Destination to which the value should be added. + */ + public list: QueryList, - /** - * A predicate which determines if a given element/directive should be included in the query - * results. - */ - predicate: QueryPredicate; + /** + * A predicate which determines if a given element/directive should be included in the query + * results. + */ + public predicate: QueryPredicate, - /** - * Values which have been located. - * - * This is what builds up the `QueryList._valuesTree`. - */ - values: any[]; + /** + * Values which have been located. + * This is what builds up the `QueryList._valuesTree`. + */ + public values: any[], - /** - * A pointer to an array that stores collected values from views. This is necessary so we know a - * container into which to insert nodes collected from views. - */ - containerValues: any[]|null; + /** + * A pointer to an array that stores collected values from views. This is necessary so we + * know a container into which to insert nodes collected from views. + */ + public containerValues: any[]|null) {} } export class LQueries_ implements LQueries { @@ -145,14 +145,7 @@ function copyQueriesToContainer(query: LQuery| null): LQuery|null { while (query) { const containerValues: any[] = []; // prepare room for views query.values.push(containerValues); - const clonedQuery: LQuery = { - next: result, - list: query.list, - predicate: query.predicate, - values: containerValues, - containerValues: null - }; - result = clonedQuery; + result = new LQuery(result, query.list, query.predicate, containerValues, null); query = query.next; } @@ -163,14 +156,7 @@ function copyQueriesToView(query: LQuery| null): LQuery|null { let result: LQuery|null = null; while (query) { - const clonedQuery: LQuery = { - next: result, - list: query.list, - predicate: query.predicate, - values: [], - containerValues: query.values - }; - result = clonedQuery; + result = new LQuery(result, query.list, query.predicate, [], query.values); query = query.next; } @@ -349,13 +335,9 @@ function createPredicate(predicate: Type| string[], read: Type| null): function createLQuery( previous: LQuery| null, queryList: QueryList, predicate: Type| string[], read: Type| null): LQuery { - return { - next: previous, - list: queryList, - predicate: createPredicate(predicate, read), - values: (queryList as any as QueryList_)._valuesTree, - containerValues: null - }; + return new LQuery( + previous, queryList, createPredicate(predicate, read), + (queryList as any as QueryList_)._valuesTree, null); } type QueryList_ = QueryList& {_valuesTree: any[], _static: boolean};