Skip to content

Commit

Permalink
Merge pull request #1589 from Polymer/1491-1578-kschaaf
Browse files Browse the repository at this point in the history
Clear input.value attribute before removing for IE. Fixes #1491. Fixe…
  • Loading branch information
kevinpschaaf committed May 22, 2015
2 parents 8578a27 + b5174da commit 65a9731
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@
// add annotation data from attributes to the `annotation` for node `node`
// TODO(sjmiles): the distinction between an `annotation` and
// `annotation data` is not as clear as it could be
// Walk attributes backwards, since removeAttribute can be vetoed by
// IE in certain cases (e.g. <input value="foo">), resulting in the
// attribute staying in the attributes list
_parseNodeAttributeAnnotations: function(node, annotation) {
for (var i=node.attributes.length-1, a; (a=node.attributes[i]); i--) {
var n = a.name, v = a.value;
Expand Down Expand Up @@ -244,6 +241,13 @@
v = v.substring(0, colon);
customEvent = true;
}
// Clear attribute before removing, since IE won't allow removing
// `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' && n == 'value') {
node.setAttribute(n, '');
}
// Remove annotation
node.removeAttribute(n);
// Case hackery: attributes are lower-case, but bind targets
Expand Down
1 change: 1 addition & 0 deletions test/unit/bind-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<span id="boundText">{{text}}</span>
<span idtest id="{{boundId}}"></span>
<s id="computedContent">{{computeFromTrickyLiterals(3, 'tricky\,\'zot\'')}}</s>
<input id="boundInput" value="{{text::input}}">
</template>
<script>
Polymer({
Expand Down
4 changes: 4 additions & 0 deletions test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
document.body.removeChild(el);
});

test('undefined input value', function() {
assert.equal(el.$.boundInput.value, '', 'undefined input value not blank');
});

test('id is bindable', function() {
assert.equal(Polymer.dom(el.root).querySelector('span[idtest]').id, 'span', 'id bound to <span> not found');
});
Expand Down

0 comments on commit 65a9731

Please sign in to comment.