Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryList initialized properties regression #21980

Closed
emilio-martinez opened this issue Feb 2, 2018 · 3 comments
Closed

QueryList initialized properties regression #21980

emilio-martinez opened this issue Feb 2, 2018 · 3 comments
Labels
area: core Issues related to the framework runtime

Comments

@emilio-martinez
Copy link
Contributor

emilio-martinez commented Feb 2, 2018

I'm submitting a...


[X] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

I believe I've found a regression issue with QueryList, possibly caused by this commit: e544742#diff-a85dbe0991a7577ea24b49374e9ae90b.

I stumbled upon this in an isolated test, i.e., I'm just testing the class logic, not rendering the component. The component has a property decorated with @ViewChildren and has other logic that depends of the QueryList length. So for testing purposes, I "manually" instantiate a QueryList because, of course, it would be automatically populated when outside of Angular's purview. This is where the issue comes in:

Previously (Angular 5.1.3, in my case), queryListInstance.length used to have an initial value of 0 because it was a getter for the _result array length. Upon upgrading to Angular 5.2.3, it's now undefined. Now to actually have it populated, the use reset() is required:

const ql = new QueryList();
console.log(ql.length); // => undefined
ql.reset([]);
console.log(ql.length); // => 0

I've only been impacted by this in isolated tests. ViewChildren's logic, however, through it's use of QueryList's reset() makes the change imperceptible when the component is rendered.

Expected behavior

const ql = new QueryList();
console.log(ql.length); // => 0, without the need to call reset()

Minimal reproduction of the problem with instructions

The below examples show how QueryList behavior changed when using new QueryList(). Also showcased, QueryLists via @ViewChildren haven't changed in practice; however, in Angular 5.2.3, the length must be getting initialized via calling reset() behind the scenes.

With Angular 5.1.3: https://stackblitz.com/edit/angular-akgclx
With Angular 5.2.3: https://stackblitz.com/edit/angular-tcnwtn

What is the motivation / use case for changing the behavior?

Regression

Environment


Angular version: 5.2.3

emilio-martinez added a commit to emilio-martinez/angular that referenced this issue Feb 2, 2018
emilio-martinez added a commit to emilio-martinez/angular that referenced this issue Feb 2, 2018
Set initial value of `length` to `0`.

Fixes regression introduced by angular@e544742#diff-a85dbe0991a7577ea24b49374e9ae90b where the `length` property ceased to have initial value.
@emilio-martinez
Copy link
Contributor Author

Added PR.

@IgorMinar IgorMinar added the area: core Issues related to the framework runtime label Feb 5, 2018
@mhevery
Copy link
Contributor

mhevery commented Feb 6, 2018

#21982

emilio-martinez added a commit to emilio-martinez/angular that referenced this issue Feb 7, 2018
Set initial value of `length` to `0`.

Fixes regression introduced by angular@e544742#diff-a85dbe0991a7577ea24b49374e9ae90b where the `length` property ceased to have initial value.

Closes angular#21980
@mhevery mhevery closed this as completed in e56de10 Feb 7, 2018
mhevery pushed a commit that referenced this issue Feb 7, 2018
Set initial value of `length` to `0`.

Fixes regression introduced by e544742#diff-a85dbe0991a7577ea24b49374e9ae90b where the `length` property ceased to have initial value.

Closes #21980

PR Close #21982
jbogarthyde pushed a commit to jbogarthyde/angular that referenced this issue Feb 23, 2018
…ngular#21982)

Set initial value of `length` to `0`.

Fixes regression introduced by angular@e544742#diff-a85dbe0991a7577ea24b49374e9ae90b where the `length` property ceased to have initial value.

Closes angular#21980

PR Close angular#21982
leo6104 pushed a commit to leo6104/angular that referenced this issue Mar 25, 2018
…ngular#21982)

Set initial value of `length` to `0`.

Fixes regression introduced by angular@e544742#diff-a85dbe0991a7577ea24b49374e9ae90b where the `length` property ceased to have initial value.

Closes angular#21980

PR Close angular#21982
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants