-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
feat(template): auto infer binding expression when empty #1963
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1963 +/- ##
==========================================
- Coverage 88.62% 88.54% -0.08%
==========================================
Files 272 272
Lines 22823 22812 -11
Branches 5292 5281 -11
==========================================
- Hits 20226 20200 -26
- Misses 2597 2612 +15 ☔ View full report in Codecov by Sentry. |
2.0.0-beta.17 (2024-05-11) **BREAKING CHANGES:** * **template:** auto infer binding expression when empty (#1963) ([3359939](3359939)) Previously only the expression of binding to element bindables get auto inferred, now it's expanded to all bindings with `.bind`/`.to-view`/`.from-view`/`.two-way`/`.one-time` Examples: ```html <div some-prop.bind=""> means <div some-prop.bind="someProp"> <div some-prop.bind> means <div some-prop.bind="someProp"> <div some-prop.one-time> means <div some-prop.one-time="someProp"> ... ``` * **convention:** rewrite runtime-html decorators (#1960) ([eaf2cd7](eaf2cd7)) With tooling in the instable state for the tc39 decorator support, we will generate standard fn call code instead of decorator. This will likely be changed when browsers start officially supporting it, or at least when the tooling (both spec & tooling stability + compat) gets better **Features:** * **template:** support spread syntax with `spread` command and ... (#1965) ([ccae63b](ccae63b)) * **repeat:** allow custom repeatable value (#1962) ([c47df91](c47df91)) **Bug Fixes:** * **compiler:** fix order when spreading custom attribute into element bindable ([ccae63b](ccae63b)) * **au-slot:** separate parent scope selection from host scope selection (#1961) ([ff605fb](ff605fb)) **Refactorings:** * **kernel:** mark side effect free (#1964) ([22c8f71](22c8f71))
@bigopon I'm trying to upgrade to Beta 17 and I'm getting a few errors as shown below in my Aurelia-Slickgrid demos, all of the code that fails have the
I don't exactly understand what I'm supposed to do in order to migrate? If I remove all the Here's code for 1 example that I have (code ref link) export class Example21 {
@bindable() selectedColumn!: Column;
@bindable() selectedOperator!: string;
@bindable() searchValue = ''; Do you have a clue what the errors are all about? Taking a look at the Bindable docs, it seems all the same. |
@ghiscoding this likely is a typing issur. Can you try |
Nvm, sorry I forgot we rewrite decorator code with convention plugin. This likely is a types issues from rewritten code. |
@ghiscoding we have a test for this scenario too in our e2e, though a difference is in our setup we use @obedm503 you don't like this change? |
I don't like implicit behavior. An empty binding should result in an error. Even |
Thanks that worked, even if it wasn't an obvious fix. 👍🏻 |
I think when faced with an empty string, we have 2 choices: strict (throw) and helpful (infer). We can choose to be strict, but I think being helpful would be nicer, especially if it's not obscure, which is the case for our change here. Whatever the expression is can be seen from the attribute, there's nothing hidden at all. |
I agree which is why I wrote here because I wasn't sure what to do since the message was confusing |
📖 Description
Our binding syntax comprises of 3 parts: target, command and expression as per the following formular:
Currently, when
expression
is absent, or empty, like the following examples:it's treated as an empty string, which means the template above works like this:
This is a missed-opportunity in v1, where we could have better dev experience, like suggested in #1259 . When the
expression
is either empty or absent, we can infer the expression based on thetarget
. so for the above example, it should be understood as:All binding commands that will share this behavior are:
.bind
.one-time
.to-view
.from-view
.two-way
.attr
This is technically a breaking change, but no-one would write anything meaningful with empty expression so the effect of this should be small, or none. Though it's still safer to have this done in beta so we don't cause unnecessary discomfort.
🎫 Issues
Close #1259
cc @fkleuver @Sayan751 @brandonseydel