Skip to content

Commit

Permalink
Fix using value$ on input element
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Nov 3, 2015
1 parent 0dc69df commit 05a1e95
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
// `value` attribute if it previously had a value (can't
// unconditionally set '' before removing since attributes with `$`
// can't be set using setAttribute)
if (node.localName == 'input' && name == 'value') {
if (node.localName === 'input' && origName === 'value') {
node.setAttribute(origName, '');
}
// Remove annotation
Expand Down
36 changes: 21 additions & 15 deletions test/unit/bind-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,26 @@
</script>

<dom-module id="x-entity-and-binding">
<template>
<p>&copy;</p>
<p id="binding">{{myText}}</p>
</template>
</dom-module>
<template>
<p>&copy;</p>
<p id="binding">{{myText}}</p>
</template>
</dom-module>

<script>
Polymer({
is: "x-entity-and-binding",
properties: {
myText: {
type: String,
value: 'binding'
}
<script>
Polymer({
is: "x-entity-and-binding",
properties: {
myText: {
type: String,
value: 'binding'
}
});
</script>
}
});
</script>

<dom-module id="x-input-value">
<template>
<input id="input" value$="{{inputValue}}">
</template>
</dom-module>
12 changes: 11 additions & 1 deletion test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<link rel="import" href="../../polymer.html">
<link rel="import" href="bind-elements.html">
<body>

<script>

suite('single-element binding effects', function() {
Expand Down Expand Up @@ -595,6 +594,17 @@
assert(!el.$.boundChild.hasAttribute('attrvalue'));
});

test('bind to value attribute on input should not fail', function() {
Polymer({
is: 'x-input-value'
});

var el = document.createElement('x-input-value');
el.inputValue = "the value";
assert.equal(el.$.input.value, "the value", "The value of the input is not propagated");
assert.equal(el.$.input.value$, undefined, "value$ should be removed from input");
});

});

suite('avoid non-bubbling event gotchas', function() {
Expand Down

0 comments on commit 05a1e95

Please sign in to comment.