Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide support for data binding with boolean properties #3768

Closed
kito99 opened this issue Jul 7, 2016 · 3 comments
Closed

Provide support for data binding with boolean properties #3768

kito99 opened this issue Jul 7, 2016 · 3 comments

Comments

@kito99
Copy link

kito99 commented Jul 7, 2016

Polymer's behavior with boolean properties is described in the docs and discussed in #1812, but I still don't see a clean solution for setting a boolean property in markup without using a hack like using an Object type or writing serialization/deserialization methods. Something like this should be possible:

<polymer-element boolean-property?="{{booleanValue}">

Using a special syntax would indicate this isn't a standard binding.

@tjsavage tjsavage added the 1.x label Sep 8, 2016
@TimvdLippe
Copy link
Contributor

Could you clarify if this issue still exists? It seems to be working now: http://jsbin.com/xavelureti/edit?html,console

@arthurevans
Copy link

Setting a boolean property from static markup (not using a binding) works fine:

<polymer-element boolean-property> => element.booleanProperty is set to true (if that is a defined property on the element). If it's not a defined property, this just sets the attribute boolean-property.

Setting a boolean property from a binding also works fine:

<polymer-element boolean-property="[[booleanValue]]"> => element.booleanProperty is set to the value of booleanValue. Note that that there's no type coercion. If booleanValue is a string value, like "false", then booleanProperty is also set to the string "false", not boolean false. If you want to coerce the value, you may need to use a computed binding, like boolean-property="[[_toBoolean(notQuiteBooleanValue)]]".

Setting a boolean attribute using a binding also works fine:

<polymer-element boolean-attribute$="[[booleanValue]]"> => boolean-attribute is set, or not set, depending on the value of booleanValue.

All these are documented, so unless we hear back from the OP I think we can close.

@kito99
Copy link
Author

kito99 commented Aug 3, 2017

Yes, this was a long time ago. We can close.

@kito99 kito99 closed this as completed Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants