Skip to content

Commit

Permalink
Merge pull request #4649 from Polymer/4630-kschaaf-undefined-textarea
Browse files Browse the repository at this point in the history
Special-case undefined textarea.value same as input. Fixes #4630
  • Loading branch information
dfreedm authored Sep 22, 2017
2 parents 6af12ac + 8aa201b commit 374d407
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@
if (binding.kind !== 'attribute') {
// Some browsers serialize `undefined` to `"undefined"`
if (binding.target === 'textContent' ||
(node.localName == 'input' && binding.target == 'value')) {
(binding.target === 'value' &&
(node.localName === 'input' || node.localName === 'textarea'))) {
value = value == undefined ? '' : value;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/unit/property-effects-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<s id="computedContent">{{computeFromTrickyLiterals(3, 'tricky\,\'zot\'')}}</s>
<s id="computedContent2">{{computeFromTrickyLiterals("(",3)}}</s>
<input id="boundInput" value="{{text::input}}">
<textarea id="boundTextArea" value="{{text::input}}"></textarea>
<div id="compound1">{{cpnd1}}{{cpnd2}}{{cpnd3.prop}}{{computeCompound(cpnd4, cpnd5, 'literalComputed')}}</div>
<div id="compound2">
literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literalComputed')}} literal4
Expand Down
8 changes: 8 additions & 0 deletions test/unit/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
assert.equal(el.$.boundInput.value, '', 'undefined input value not blank');
});

test('undefined textarea value', function() {
assert.equal(el.$.boundTextArea.value, '', 'undefined textarea value not blank');
el.text = 'this is a test';
assert.equal(el.$.boundTextArea.value, 'this is a test', 'binding to textarea didn\'t go');
el.text = undefined;
assert.equal(el.$.boundTextArea.value, '', 'undefined textarea value not blank');
});

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

0 comments on commit 374d407

Please sign in to comment.