Set initial value of `length` to `0`.
Fixes regression introduced by e544742156 (diff-a85dbe0991a7577ea24b49374e9ae90b)
where the `length` property ceased to have initial value.
Closes #21980
PR Close #21982
This commit is contained in:
parent
64ae6d206e
commit
e56de1025a
|
@ -41,7 +41,7 @@ export class QueryList<T>/* implements Iterable<T> */ {
|
|||
private _results: Array<T> = [];
|
||||
public readonly changes: Observable<any> = new EventEmitter();
|
||||
|
||||
readonly length: number;
|
||||
readonly length: number = 0;
|
||||
readonly first: T;
|
||||
readonly last: T;
|
||||
|
||||
|
|
|
@ -23,6 +23,22 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
|||
|
||||
function logAppend(item: any /** TODO #9100 */) { log += (log.length == 0 ? '' : ', ') + item; }
|
||||
|
||||
describe('dirty and reset', () => {
|
||||
|
||||
it('should initially be dirty and empty', () => {
|
||||
expect(queryList.dirty).toBeTruthy();
|
||||
expect(queryList.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should be not dirty after reset', () => {
|
||||
expect(queryList.dirty).toBeTruthy();
|
||||
queryList.reset(['one', 'two']);
|
||||
expect(queryList.dirty).toBeFalsy();
|
||||
expect(queryList.length).toBe(2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should support resetting and iterating over the new objects', () => {
|
||||
queryList.reset(['one']);
|
||||
queryList.reset(['two']);
|
||||
|
|
Loading…
Reference in New Issue