aurelia / templating-resources

A standard set of behaviors, converters and other resources for use with the Aurelia templating library.
MIT License
59 stars 55 forks source link

[Feature] Support default binding mode for html only components #380

Open michaelw85 opened 5 years ago

michaelw85 commented 5 years ago

I'm submitting a feature request

Please tell us about your environment:

Current behavior: Settings default binding mode requires a class using the decorator.

Expected/desired behavior: Expected to be able to set a default binding mode on view only custom elements in html

Here's an old PR introducing the functionality: https://github.com/aurelia/templating-resources/pull/309

bigopon commented 5 years ago

cc @EisenbergEffect

EisenbergEffect commented 5 years ago

@bigopon I think we should implement this in vNext first, as part of the template parser. Then, once we've got all the details settled, port it back to vCurrent. My thinking is that this will give us a better chance of remaining forward/backward compatible with the new feature. We also may be able to do more in vNext and that might give us a clearer picture of what subset is doable with vNext.

EisenbergEffect commented 5 years ago

We should support both types and default binding modes. Prefer a syntax that matches TypeScript for the type part. Maybe it's something like myProperty: number & twoWay. (Probably need to differentiate int and float actually.)

michaelw85 commented 5 years ago

@EisenbergEffect I like the format @bigopon already used in his initial PR. Only thing I would like to suggest is to match the template spinal case notation of the binding mode. I think this would be intuitive since you are already in the html context.

<template bindable="myProperty: number & two-way">
...
</template>

Alternatively we could match the html format like so: myProperty.to-way: number

We should support both types and default binding modes.

I think this is great and would love to have both but from a development point of view these are separate features in my opinion.