do as it was, if the value is undefined, the attribute should not be created
version 0.6:
<a href="${item.link}" ></a> --> <a href="undefined"></a>
version 0.5.2:
<a href="${item.link}" ></a> --> <a></a>
@Leon-Alexey please read the changelog and docs carefully before starting to complain.
The binding notation has been changed in 0.5.2 so you should now bind to a property:
<a .href="${item.link}"></a>
<a .href="${item.link}"></a>
It's not working
if (item.link !== undefined) {
return html'<a href="${item.link}"></a>'
} else {
retun html'<a></a>'
}
if need add 10 attributes then to make 10 'if'
@Leon-Alexey ok, the href is still attribute, so the proper solution would be to use directive:
import { ifDefined } from 'lit-html/directives/if-defined.js';
and then use it like this:
<a href="${ifDefined(item.link)}"></a>
See working demo here: https://glitch.com/edit/#!/linen-bonsai?path=index.html:17:4
works, Thanks!
Most helpful comment
@Leon-Alexey ok, the
hrefis still attribute, so the proper solution would be to use directive:and then use it like this:
See working demo here: https://glitch.com/edit/#!/linen-bonsai?path=index.html:17:4