angular.js
angular.js copied to clipboard
ng-options with track by and circular reference in objects -> Maximum call stack size exceeded
Observed in 1.4.8, but looking at the code, it seems to be an issue in 1.5 as well.
Reproduced here: http://jsfiddle.net/tn102eh8/2/ (1.4.8) And here: http://jsfiddle.net/tn102eh8/3/ (1.5.0-beta2) Related to #11372
The issue seems to be that ng-options runs equals(previousValue, nextValue) if trackby is used https://github.com/angular/angular.js/blob/master/src/ng/directive/ngOptions.js#L737
I think it should do
if (ngOptions.trackBy) {
var prev = ngOptions.getTrackByValue(previousValue, ngOptions.trackBy);
var next = ngOptions.getTrackByValue(nextValue, ngOptions.trackBy)
}
And then use angular.equals(prev, next) instead. I don't have an env. for angular development at the moment, but if you agree that this is an issue, I guess I can set it up and do a PR.
We do have a test for circular references, but it doesn't use track by, so I think we can expect this to work. If you want to open a PR, we are happy to look at it.
Any update on this?
No, not yet. I'll take a look this week if nobody beats me to it. @studds if you want to open a PR with the change suggestion I'll be happy to look at it.
Hi, what is the status of this issue? I found several issues dealing with the same problem, but none seems to be really closed. And indeed it seems that the problem still occurs in AngularJS 1.5.8.
BTW, I tried the fix suggested by rasmusvhansen and it works (and seems relevant).
@Jimmy-Lopez No time yet. A PR with the proposed fix by you or anyone else wold definitely speed things up.