Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ng-options with track by and circular reference in objects -> Maximum call stack size exceeded #13378

Open
rasmusvhansen opened this issue Nov 25, 2015 · 5 comments

Comments

@rasmusvhansen
Copy link

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.

@Narretz
Copy link
Contributor

Narretz commented Nov 29, 2015

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.

@studds
Copy link

studds commented Apr 11, 2016

Any update on this?

@Narretz
Copy link
Contributor

Narretz commented Apr 11, 2016

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.

@Jimmy-Lopez
Copy link

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).

@Narretz
Copy link
Contributor

Narretz commented Aug 9, 2016

@Jimmy-Lopez No time yet. A PR with the proposed fix by you or anyone else wold definitely speed things up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants