Skip to content

Commit

Permalink
Merge pull request #2099 from riot/fix/2096
Browse files Browse the repository at this point in the history
Fix #2096
  • Loading branch information
GianlucaGuarini committed Nov 26, 2016
2 parents 3083ae2 + 001c253 commit bb7441f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/browser/tag/update.js
Expand Up @@ -70,7 +70,7 @@ export function updateExpression(expr) {
var dom = expr.dom,
attrName = expr.attr,
value = tmpl(expr.expr, this),
isValueAttr = attrName === 'value',
isValueAttr = attrName === 'riot-value',
isVirtual = expr.root && expr.root.tagName === 'VIRTUAL',
parent = dom && (expr.parent || dom.parentNode),
old
Expand Down
14 changes: 14 additions & 0 deletions test/specs/browser/core.spec.js
Expand Up @@ -25,6 +25,7 @@ import '../../tag/multi-named.tag'
import '../../tag/named-data-ref.tag'
import '../../tag/input-number.tag'
import '../../tag/input-values.tag'
import '../../tag/input-updated.tag'
import '../../tag/nested-riot.tag'
import '../../tag/treeview.tag'
import '../../tag/events.tag'
Expand Down Expand Up @@ -741,6 +742,19 @@ describe('Riot core', function() {
tag.unmount()
})

it('updates the value of input which has been changed from initial one', function() {

injectHTML('<input-updated></input-updated>')

var tag = riot.mount('input-updated')[0]
expect(tag.refs.i.value).to.be.equal('Hello, Riot!')
tag.refs.i.value = 'Hi!'
fireEvent(tag.refs.b, 'click')
expect(tag.refs.i.value).to.be.equal('Can you hear me?')

tag.unmount()
})

it('recursive structure', function() {
injectHTML('<treeview></treeview>')
var tag = riot.mount('treeview')[0]
Expand Down
11 changes: 11 additions & 0 deletions test/tag/input-updated.tag
@@ -0,0 +1,11 @@
<input-updated>
<h3>{ message }</h3>
<input ref="i" value="{ message }">
<button ref="b" onclick={ setOtherValue }>Click me!</button>
<script>
this.message = 'Hello, Riot!'
setOtherValue () {
this.message = 'Can you hear me?'
}
</script>
</input-updated>

0 comments on commit bb7441f

Please sign in to comment.