Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

md-chips causes stack overflow when data objects have circular references #5778

Closed
rich-j opened this issue Nov 17, 2015 · 2 comments
Closed
Assignees
Labels
P1: urgent Urgent issues that should be addressed in the next minor or patch release.
Milestone

Comments

@rich-j
Copy link

rich-j commented Nov 17, 2015

The <md-chips> and <md-contact-chips> directives can cause a stack overflow when the data objects have a circular reference. This worked up until RC2 when this fix(md-chips): appendChip disallows identical objects #4479 changed MdChipsCtrl.prototype.appendChip by adding a call to angular.equals() which doesn't support circular references. Here is a codepen (http://codepen.io/rich-j/pen/RWvymm?editors=101) that shows the issue. Try adding another "person" to the contact chips.

Angular's equals() function has several unimplemented requests for circular reference support:

Each "person" in our system is a single object that has references to related objects (e.g. parent/child, owner/member). We would like to pass these "person" instances directly to <md-contact-chips>. The Angular equals() function does work for object equality (i.e. same object references) however for unequal objects it can get stuck in a cycle since it unfortunately implements a depth first search on object properties.

@topherfangio
Copy link
Contributor

Just brainstorming a bit; perhaps we should offer a way to provide a custom equals function?

@robertmesserle Any thoughts?

@robertmesserle
Copy link
Contributor

Hm, that could work. We could also look for circular references when
iterating through objects. Probably a good idea to do both.

On Tue, Dec 1, 2015 at 2:49 PM, Topher Fangio notifications@github.com
wrote:

Just brainstorming a bit; perhaps we should offer a way to provide a
custom equals function?

@robertmesserle https://github.com/robertmesserle Any thoughts?


Reply to this email directly or view it on GitHub
#5778 (comment).

@topherfangio topherfangio added this to the 1.1.0 milestone Jan 6, 2016
@ThomasBurleson ThomasBurleson added P1: urgent Urgent issues that should be addressed in the next minor or patch release. and removed priority: medium labels Jan 15, 2016
@ThomasBurleson ThomasBurleson modified the milestones: 1.1.0, Backlog Jan 15, 2016
@ThomasBurleson ThomasBurleson modified the milestones: Backlog, Deprecated Apr 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1: urgent Urgent issues that should be addressed in the next minor or patch release.
Projects
None yet
Development

No branches or pull requests

4 participants