When you change input manually and then try to set the value of an object that was before, riot doesn't change the value in input.
http://plnkr.co/edit/pvDCkA45DvlB82X0c1h1
I thought this was fixed :(
Me, too. I'm looking into it again...
Actually #2096 has been fixed.
http://plnkr.co/edit/ybvigX18VUAOk4yKR7KI?p=preview
But why this doesn't work...
I've found that it was true on Riot 2.6.7, too.
http://plnkr.co/edit/nFUx1uKyxSvClKmtjTsK?p=preview
Moreover, it was true on 2.4.1!
Actually, I really can't imagine how such bug wasn't observed earlier.
Simply because of this line:
https://github.com/riot/riot/blob/v3.0.1/lib/browser/tag/update.js#L107
@wolandec in usual use cases, this doesn't matter because the internal value would be changed every time basically. I'm not sure I saw a discussion about it before...
We could fix this issue by the code like this:
if (old === value && !isValueAttr || dom.value === value) return
@cognitom ah yeah of course this is not a bug sorry It was already discussed here https://github.com/riot/riot/issues/1642
@GianlucaGuarini thanks for pointing out!
I've added a negative test to dev for the clarification. 799c02416f60f5285538e81f160dd22521760762
@wolandec I think it's ok in 99.9% of the case. A real world example could be like this:
http://plnkr.co/edit/iFaYIqTxh3P9M98NZyqk?p=preview
Note: the only difference between your plunker is change method.
@cognitom it's interesting to notice that vue also behaves in the same way http://jsfiddle.net/gianlucaguarini/a2p3nahv/
@cognitom Yes, I saw that example at the discussion. So, I have to make such methods to all inputs, and make all that noise in code?
Maybe it is worth to make a discussion about the "updateFlag" or something?
@wolandec we already have discussion about flag on #1642. I'm not sure we got clear consensus or not.
Here's another work around (bit more ugly) at this point:
this.update({ message: '' })
this.message = 42
Even though I have never encounter such a situation I had to use it...
this is enough http://plnkr.co/edit/MJnA0MSeuBtRup5h035d?p=preview
@GianlucaGuarini It looks like a little bit tricky, but seemingly this is an only variant to use.
Bit tricky but cool 馃槑
@cognitom Yeah, that's right.
@wolandec try the same thing with react just for fun :P you will have a big surprise
@GianlucaGuarini I am feeling sick seeing the reactjs code.
What is the best practice?
For example, is it the way of empty updating or the way of re-updating on input event?