aurelia / templating-binding

An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.
MIT License
32 stars 26 forks source link

Improve (static) binding to boolean #112

Closed ZoolWay closed 7 years ago

ZoolWay commented 7 years ago

I'm submitting a feature request

Current behavior: When having a custom component with a bindable value which should be a boolean to have a switch on your component, it is hard to activate it without using a binding / variable because the attribute value "true" is a string which evaluates to false.

You have to use a binding (if the value is static, one-time is appropiate) to have a boolean value be recognized.

See: https://gist.run/?id=8204ba8ba4b1e37baa84eed0dcc5457f

Expected/desired behavior: If my component member variable is a boolean it would be nice to have a proper conversion from the string attribute value "true" to that type. Of course knowing if the member is a boolean is only possible with TypeScript (which I use). For ESnext maybe we could configure some kind of global conversion of the string "true" to the boolean value true for bindables? For "false" the difference does not matter as long as I do not use three equal operations ===.

What is the motivation / use case for changing the behavior? Setting component bindable value to static value without using a binding feels much more natural for the developer. If you want to enable it,

<my-comp is-awesome="true"></my-comp>

feels much more intuitive than the current necessary approach

<my-comp is-awesome.one-time="true"></my-comp>

Also to not use a binding might improve performance (although one-time should not be a great hit on performance).

Notes Similar conversion might be interesting for numbers, too.

EisenbergEffect commented 7 years ago

Closing this as a dupe. We're planning to enable typed bindables which would convert properties automatically without the need to use the binding as you have above. Thanks for the feedback!

ZoolWay commented 7 years ago

@EisenbergEffect Thanks for your response Rob! Is there a place where I can get to know about upcoming planned features?

EisenbergEffect commented 7 years ago

Only searching issues tagged as enhancement.

On Mar 27, 2017 12:10 AM, "Ricky Blankenaufulland" notifications@github.com wrote:

@EisenbergEffect https://github.com/EisenbergEffect Thanks for your response Rob! Is there a place where I can get to know about upcoming planned features?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/templating-binding/issues/112#issuecomment-289371475, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIBnczTLUPP0d3bYskymWjkCVkCknJGks5rp2DngaJpZM4MoFoa .

jdanyow commented 7 years ago

https://github.com/aurelia/templating/issues/96