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

@bindable({ primaryProperty: true }) does not work for camel-case property names. #122

Closed nenadvicentic closed 6 years ago

nenadvicentic commented 6 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: Primary property binding does not work for camel-cased property names.


export class TrackLinkCustomAttribute
{
    @bindable({ primaryProperty: true})
    public linkType: "link" | "download";
}

Shorthand binding expression does not work: <a track-link="download" href=... >

Longer binding syntax works as expected: <a track-link="link-type: download" href=... >

Once property is renamed into lowercase, shorthand binding syntax start to work too.

Expected/desired behavior:

primaryProperty should work for both lower-case and camel-case property names.

StrahilKazlachev commented 6 years ago

What version of aurelia-templating? I think the fix for this is out in aurelia-templating@1.7.0.

nenadvicentic commented 6 years ago

I just checked. I am using aurelia-templating@1.7.0.

Bellow are versions of related packages:

"aurelia-templating": "1.7.0", "aurelia-templating-binding": "1.4.0", "aurelia-templating-resources": "1.5.4", "aurelia-templating-router": "1.3.1"

StrahilKazlachev commented 6 years ago

Just checked and it works as expected with aurelia-templating@1.7.0. Things you can check:

nenadvicentic commented 6 years ago

I just double checked and managed to reproduce the bug again.

Code that was fixed in aurelia-templating@1.7.0 is here: https://github.com/aurelia/templating/commit/5a2276c

I debugged those lines (screenshot), so I am definitely running version 1.7.0. Parsing of my custom-attribute property-names does not go through this lines of code at all. Here is example where it parses if binding.

aurelia-template-not-a-problem

Is it possible that the problem are lines code bellow? You can see that both name and attrName have same, camel case value, in my case eventName:

aurelia-template-binding-problem

Those lines of code are part of [SyntaxInterpreter](https://github.com/aurelia/templating-binding/blob/master/src/syntax-interpreter.js) class in master.

StrahilKazlachev commented 6 years ago

Not sure, haven't looked at those lines. Can do later tonight. If you can setup a simple repro I'll debug it - as a github repo will be easiest.

nenadvicentic commented 6 years ago

Here is the repo: https://github.com/nenadvicentic/aurelia-template-binding-primary-property-not-working

Default aurelia-cli project, just two buttons added on the page. First button using shorthand syntax and having an error. Second one using longer syntax, binding correctly.

StrahilKazlachev commented 6 years ago

Will check it after work, but the first difference I see with what I tried is I did .bind - track-click.bind="'Hello from Button 1'" I didn't notice how you used it in the first example.

StrahilKazlachev commented 6 years ago

@nenadvicentic you can test #123 if you want.

nenadvicentic commented 6 years ago

@StrahilKazlachev, I tried your fix in my repro. It works fine now. Thx