I need to have an attribute which can have value of zero (0
)
Riot template:
<my-tag time="{ time }">
this.time = condition ? '10' : '0'
</my-tag>
Desired result:
<my-tag time="0"></my-tag>
However, Riot automatically omits whole attribute if it has falsy value:
<my-tag></my-tag>
My current workaround:
this.on('updated', () => {
$(this.root).attr('time', this.time)
})
In other words, i need time
attribute to have exact value of time
property.
Edit:
Looks like this has changed since 2.2.4.
Demo with Riot 2.2.4
this works as expected - both tags have rendered attribute time
with according value
Demo with Riot 2.3.13
this fails - tag with attribute set to false
has whole attribute removed
This is working in riot v2.3.18:
<my-tag time="{ time ? '10' : '0'}">
<script>
this.time = false;
</script>
</my-tag>
will generate
<my-tag time="0"></my-tag>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With