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

angular.equals cannot compare some objects with circular references #14953

Closed
robianmcd opened this issue Jul 26, 2016 · 1 comment
Closed

angular.equals cannot compare some objects with circular references #14953

robianmcd opened this issue Jul 26, 2016 · 1 comment

Comments

@robianmcd
Copy link

robianmcd commented Jul 26, 2016

Do you want to request a feature or report a bug?
bug

What is the current behavior?

var a = {};
a.a = a;
angular.equals(a, angular.copy(a)); 
//Throws: Uncaught RangeError: Maximum call stack size exceeded

https://plnkr.co/edit/GWPdEXjZju6flBAUl4VW?p=preview

What is the expected behavior?
angular.equals(a, angular.copy(a)) returns true

What is the motivation / use case for changing the behavior?
For me this is coming up when a user wants to edit a model. First I make a copy of the model so that any changes can be canceled. Then when the user tries to save their changes I compare the copy with the original to see if anything actually needs to be saved.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Tested with Angular 1.5 in Chrome

@Narretz
Copy link
Contributor

Narretz commented Jul 26, 2016

Duplicate of #14512

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

2 participants