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

Conditional attributes #338

Closed Dissolubilis closed 8 years ago

Dissolubilis commented 8 years ago

You have mentioned in #117 that the the linked attributes will be removed if its value is null or empty. However I cannot approach it. For example linking to

<a data-link="href{:null}"> I am not the link</a>

will provide

<a data-link="href{:null}" href="">I am not the link</a>

And desired effect is:

<a data-link="href{:null}" >I am not the link</a>

Simple jsfiddle is here - https://jsfiddle.net/vLmsnmrx/6/

I tried null, undefined and empty string. What am I doing wrong?

BorisMoore commented 8 years ago

Thanks for calling this out. You are right, this is a regression. I have a fix ready, which I will include in the next update. With the fix you will be able to use either undefined or null and the attribute will be removed. Let me know if it is urgent for you, and I could send you a private fix...

Dissolubilis commented 8 years ago

Thanks. If the next update is not coming soon, then it will be great to get your fix

BorisMoore commented 8 years ago

In fact the fix is to replace: https://github.com/BorisMoore/jsviews/blob/master/jsviews.js#L2023

: (getsVal = true, "((v=" + params[0] + ')!=null?v:"")')

by

: (getsVal = true, "((v=" + params[0] + ')!=null?v:' + (isLinkExpr ? 'null)' : '"")'))
Dissolubilis commented 8 years ago

Thank you. It is working after applying the fix.

BorisMoore commented 8 years ago

This is fixed in commit 78.