Skip to content

Commit b759d63

Browse files
committed
revert: refactor(ivy): Update query-related comments (angular#29342)
1 parent fe759ee commit b759d63

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

packages/core/src/linker/query_list.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,20 @@ export class QueryList<T>/* implements Iterable<T> */ {
9393
return this._results.some(fn);
9494
}
9595

96-
/**
97-
* Returns a copy of the internal results list as an Array.
98-
*/
9996
toArray(): T[] { return this._results.slice(); }
10097

10198
[getSymbolIterator()](): Iterator<T> { return (this._results as any)[getSymbolIterator()](); }
10299

103100
toString(): string { return this._results.toString(); }
104101

105-
/**
106-
* Updates the stored data of the query list, and resets the `dirty` flag to `false`, so that
107-
* on change detection, it will not notify of changes to the queries, unless a new change
108-
* occurs.
109-
*
110-
* @param resultsTree The results tree to store
111-
*/
112-
reset(resultsTree: Array<T|any[]>): void {
113-
this._results = depthFirstFlatten(resultsTree);
102+
reset(res: Array<T|any[]>): void {
103+
this._results = flatten(res);
114104
(this as{dirty: boolean}).dirty = false;
115105
(this as{length: number}).length = this._results.length;
116106
(this as{last: T}).last = this._results[this.length - 1];
117107
(this as{first: T}).first = this._results[0];
118108
}
119109

120-
/**
121-
* Triggers a change event by emitting on the `changes` {@link EventEmitter}.
122-
*/
123110
notifyOnChanges(): void { (this.changes as EventEmitter<any>).emit(this); }
124111

125112
/** internal */
@@ -132,9 +119,9 @@ export class QueryList<T>/* implements Iterable<T> */ {
132119
}
133120
}
134121

135-
function depthFirstFlatten<T>(list: Array<T|T[]>): T[] {
122+
function flatten<T>(list: Array<T|T[]>): T[] {
136123
return list.reduce((flat: any[], item: T | T[]): T[] => {
137-
const flatItem = Array.isArray(item) ? depthFirstFlatten(item) : item;
124+
const flatItem = Array.isArray(item) ? flatten(item) : item;
138125
return (<T[]>flat).concat(flatItem);
139126
}, []);
140127
}

packages/core/src/render3/query.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,7 @@ export function query<T>(
365365
/**
366366
* Refreshes a query by combining matches from all active views and removing matches from deleted
367367
* views.
368-
*
369-
* @returns `true` if a query got dirty during change detection or if this is a static query
370-
* resolving in creation mode, `false` otherwise.
368+
* Returns true if a query got dirty during change detection, false otherwise.
371369
*/
372370
export function queryRefresh(queryList: QueryList<any>): boolean {
373371
const queryListImpl = (queryList as any as QueryList_<any>);

packages/core/test/render3/query_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,6 @@ describe('query', () => {
16031603
});
16041604

16051605
// https://stackblitz.com/edit/angular-7vvo9j?file=src%2Fapp%2Fapp.component.ts
1606-
// https://stackblitz.com/edit/angular-xzwp6n
16071606
it('should report results when the same TemplateRef is inserted into different ViewContainerRefs',
16081607
() => {
16091608
let tpl: TemplateRef<{}>;

tools/public_api_guard/core/core.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ export declare class QueryList<T> {
721721
map<U>(fn: (item: T, index: number, array: T[]) => U): U[];
722722
notifyOnChanges(): void;
723723
reduce<U>(fn: (prevValue: U, curValue: T, curIndex: number, array: T[]) => U, init: U): U;
724-
reset(resultsTree: Array<T | any[]>): void;
724+
reset(res: Array<T | any[]>): void;
725725
setDirty(): void;
726726
some(fn: (value: T, index: number, array: T[]) => boolean): boolean;
727727
toArray(): T[];

0 commit comments

Comments
 (0)