BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
855 stars 130 forks source link

?: operator in css-height and css-width #331

Closed Mytia closed 8 years ago

Mytia commented 8 years ago

Little bug here

http://jsfiddle.net/y43cs47y/9/

Error in console. It works if wrap ~height?~height:100 with brackets. The same thing with css-width, maybe with something else...

BorisMoore commented 8 years ago

Yes, the issue there is that your syntax conflicts with the syntax for two-way binding with a convertBack converter:

<input data-link="{cvt:name:cvtBack}" >

I have a parser fix prepared for the next update, but for now you can use any of the following forms to make the ternary statement work without conflict in the current version of the parser:

{:~height ? ~height : 100}
{:~height?~height: 100}
{:~height?~height:100 }
{:(~height?~height:100)}

All of the above make it clear that this is not two-way binding.

BTW the issue is not specific to css-height or css-width at all...

Mytia commented 8 years ago

Yes, thanks, the same thing with tag args and params

http://jsfiddle.net/y43cs47y/13/

BorisMoore commented 8 years ago

Correct - they are also fixed in the change I have for the next update...

BorisMoore commented 8 years ago

This has been fixed with update v0.9.72.

See http://jsfiddle.net/y43cs47y/9/ and http://jsfiddle.net/y43cs47y/14/