Fix issue with gr-select when value is 0

There was an issue with gr-select that when the bound value is 0, the
native value was not set properly because of the way the value was
checked. This change fixes the issue by explicitly checking for
undefined rather than falsy value.

Change-Id: I1ef33cdb99933e5d2a8ba1fd9360266e8d258eaf
This commit is contained in:
Becky Siegel
2017-12-05 17:07:26 -08:00
parent 23622a0149
commit aae6d670a5
2 changed files with 7 additions and 1 deletions

View File

@@ -34,7 +34,8 @@
},
_updateValue() {
if (this.bindValue) {
// It's possible to have a value of 0.
if (this.bindValue !== undefined) {
// Set for chrome/safari so it happens instantly
this.nativeSelect.value = this.bindValue;
// Async needed for firefox to populate value. It was trying to do it

View File

@@ -45,6 +45,11 @@ limitations under the License.
element = fixture('basic');
});
test('value of 0 should still trigger value updates', () => {
element.bindValue = 0;
assert.equal(element.nativeSelect.value, 0);
});
test('bidirectional binding property-to-attribute', () => {
const changeStub = sinon.stub();
element.addEventListener('bind-value-changed', changeStub);