Riot.js 2: False Value Attribute
I need to have an attribute that can have a value of 0 ( 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 the entire attribute if it has a false value:
<my-tag></my-tag> My current workaround:
this.on('updated', () => { $(this.root).attr('time', this.time) }) In other words, I need the time attribute in order to have the exact value of the time property.
Edit:
It looks like this has changed from 2.2.4.
this works as expected - both tags display the time attribute with the corresponding value
this failure: a tag with an attribute set to false deleted the entire attribute
Try prefixing your attribute with "riot -"
<my-tag riot-time="{ time }"> I had a similar problem
<div class="fldr" data-stat="{ s }"> When s = 0, displayed as
<div class="fldr"> This worked in my case.
<div class="fldr" riot-data-stat="{ s }"> Note that I am not using the Riot compiler, I am writing Javascript that the compiler will create, you may have to bypass the Riot compiler for this. Just look at your compiled my-tag.js and go from there.
Riot API docs at riot.tag () http://riotjs.com/api/#manual-construction