PolymerElements / iron-component-page

A reusable landing page for elements
36 stars 32 forks source link

hidden$="[[_activeDescriptor]]" causes JSON serialization error #33

Closed atotic closed 4 years ago

atotic commented 9 years ago

_activeDescriptor is a big doc, and a circular structure. Trying to JSON.serialize(_activeDescriptor) throws "TypeError: Converting circular structure to JSON"

It is very sensible to bind it to a hidden attribute.

It is not sensible for Polymer to serialize _activeDescriptor just to set a boolean.

notwaldorf commented 8 years ago

Right now the solution is to make a computed function that casts the object to a boolean. (this should be a very quick fix)

justinfagnani commented 8 years ago

@atotic I know this is old, but do you have an example I can reproduce this on?

atotic commented 8 years ago

Dang, this is old, I forget where I encountered it in the wild. To reproduce, create a cyclical object:

var  x = {};
x.cycle = x;
JSON.stringify(x) will throw cyclic object value error.

Then, bind x to a boolean value. I think this should work:

<input hidden$="{{x}}">

and you'll get the error.