From 8aa201b9ade9ed7b282a82f291f660c1113e1896 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 31 May 2017 11:31:12 -0700 Subject: [PATCH] Special-case undefined textarea.value same as input. Fixes #4630 --- lib/mixins/property-effects.html | 3 ++- test/unit/property-effects-elements.html | 1 + test/unit/property-effects.html | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 9dc5d3273e..e23d6fb299 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -598,7 +598,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; } } diff --git a/test/unit/property-effects-elements.html b/test/unit/property-effects-elements.html index 0d9853cde0..34e9113892 100644 --- a/test/unit/property-effects-elements.html +++ b/test/unit/property-effects-elements.html @@ -63,6 +63,7 @@ {{computeFromTrickyLiterals(3, 'tricky\,\'zot\'')}} {{computeFromTrickyLiterals("(",3)}} +
{{cpnd1}}{{cpnd2}}{{cpnd3.prop}}{{computeCompound(cpnd4, cpnd5, 'literalComputed')}}
literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literalComputed')}} literal4 diff --git a/test/unit/property-effects.html b/test/unit/property-effects.html index bc6404e0c0..2632cf032b 100644 --- a/test/unit/property-effects.html +++ b/test/unit/property-effects.html @@ -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 not found'); });