You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SelectControlValueAccessor.compareWith: 25 tests for 5 options seems excessive #19723
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] 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
When using compareWith on a <select> with only 5 options, compareWith function is being called 25 times.
On initialization of the form, 15 runs are tested against undefined, 5 against null and 5 against an object.
On refresh of the option list, 25 runs are tested against an object in a peculiar order.
This happens both in development and production.
Expected behavior
I would expect it to test between 1 and max. 5 times depending on the selected option
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Performance
Environment
Angular version: 4.4.5
Browser:
- [x] Chrome (desktop) version 61.0.3163.100 (Official Build) (64-bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
- [x] Electron version 1.7.8
For Tooling issues:
- Node version: v8.5.0
- Platform: Windows 10
Others:
The numbers mentioned were taken from the plunker in production mode...
I'm puzzled... Are 12 or 13 calls to compare an id against a list of 5 really to be expected???
Would you consider the following outcome where compareWith is run 5 times over the entire set of options after a data refresh and skipping successful hits as being a non-issue?
After initialization of view
comparing: id 1 with id undefined
comparing: id 1 with id undefined
comparing: id 2 with id undefined
comparing: id 1 with id undefined
comparing: id 2 with id undefined
comparing: id 3 with id undefined
comparing: id 1 with id undefined
comparing: id 2 with id undefined
comparing: id 3 with id undefined
comparing: id 4 with id undefined
comparing: id 1 with id undefined
comparing: id 2 with id undefined
comparing: id 3 with id undefined
comparing: id 4 with id undefined
comparing: id 5 with id undefined
comparing: id 1 with id null
comparing: id 2 with id null
comparing: id 3 with id null
comparing: id 4 with id null
comparing: id 5 with id null
comparing: id 1 with id 5
comparing: id 2 with id 5
comparing: id 3 with id 5
comparing: id 4 with id 5
comparing: id 5 with id 5 -> true
Refresh data
comparing: id 2 with id 5
comparing: id 3 with id 5
comparing: id 4 with id 5
comparing: id 5 with id 5 -> true
comparing: id 3 with id 5
comparing: id 4 with id 5
comparing: id 5 with id 5 -> true
comparing: id 4 with id 5
comparing: id 5 with id 5 -> true
comparing: id 5 with id 5 -> true
comparing: id 1 with id 5
comparing: id 1 with id 5
comparing: id 2 with id 5
comparing: id 1 with id 5
comparing: id 2 with id 5
comparing: id 3 with id 5
comparing: id 1 with id 5
comparing: id 2 with id 5
comparing: id 3 with id 5
comparing: id 4 with id 5
comparing: id 1 with id 5
comparing: id 2 with id 5
comparing: id 3 with id 5
comparing: id 4 with id 5
comparing: id 5 with id 5 -> true
Activity
Toxicable commentedon Oct 14, 2017
I don't see an issue here, remember that in debug mode all CD is run twice, so in prod mode you'd only see 12 or 13 calls
pamtbaau commentedon Oct 14, 2017
The numbers mentioned were taken from the plunker in production mode...
I'm puzzled... Are 12 or 13 calls to compare an id against a list of 5 really to be expected???
Would you consider the following outcome where
compareWithis run 5 times over the entire set of options after a data refresh and skipping successful hits as being a non-issue?kara commentedon Dec 5, 2017
We should probably take a closer look and see if all these calls are needed or if there's a more efficient way to do this.
AndrewKushnir commentedon Mar 23, 2021
FYI, closing this ticket in favor of #41330, which has more up-to-date repro.
angular-automatic-lock-bot commentedon Apr 23, 2021
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.