From 001c253fd67527f819ef9d8f681b4dd06a1be04f Mon Sep 17 00:00:00 2001 From: Tsutomu Kawamura Date: Sun, 27 Nov 2016 00:08:21 +0900 Subject: [PATCH] Fix #2096 --- lib/browser/tag/update.js | 2 +- test/specs/browser/core.spec.js | 14 ++++++++++++++ test/tag/input-updated.tag | 11 +++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/tag/input-updated.tag diff --git a/lib/browser/tag/update.js b/lib/browser/tag/update.js index 28417c1215..e7b09ab298 100644 --- a/lib/browser/tag/update.js +++ b/lib/browser/tag/update.js @@ -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 diff --git a/test/specs/browser/core.spec.js b/test/specs/browser/core.spec.js index 8a58a6e3d6..34c6cce818 100644 --- a/test/specs/browser/core.spec.js +++ b/test/specs/browser/core.spec.js @@ -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' @@ -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('') + + 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('') var tag = riot.mount('treeview')[0] diff --git a/test/tag/input-updated.tag b/test/tag/input-updated.tag new file mode 100644 index 0000000000..7a4edb88dc --- /dev/null +++ b/test/tag/input-updated.tag @@ -0,0 +1,11 @@ + +

{ message }

+ + + +