Skip to content

Commit

Permalink
Clear input.value attribute before removing for IE. Fixes #1491. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed May 22, 2015
1 parent a640b7e commit 1dea50f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 5 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,11 @@
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
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 @@ -18,6 +18,7 @@
</div>
<span id="boundText">{{text}}</span>
<span idtest id="{{boundId}}"></span>
<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 1dea50f

Please sign in to comment.