From fd98a5591d0c952e3dbbd64aa51afb9dc553fde0 Mon Sep 17 00:00:00 2001 From: Michel Blankenstein Date: Wed, 16 Oct 2019 11:37:45 +0200 Subject: [PATCH] fix(radio-group): change check of value to only null or undefined --- packages/radio-group/src/LionRadioGroup.js | 2 +- packages/radio-group/test/lion-radio-group.test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/radio-group/src/LionRadioGroup.js b/packages/radio-group/src/LionRadioGroup.js index a70fcc695..2e9cc90d8 100644 --- a/packages/radio-group/src/LionRadioGroup.js +++ b/packages/radio-group/src/LionRadioGroup.js @@ -94,7 +94,7 @@ export class LionRadioGroup extends LionFieldset { __triggerCheckedValueChanged() { const value = this.checkedValue; - if (value && value !== this.__previousCheckedValue) { + if (value != null && value !== this.__previousCheckedValue) { this.dispatchEvent( new CustomEvent('checked-value-changed', { bubbles: true, composed: true }), ); diff --git a/packages/radio-group/test/lion-radio-group.test.js b/packages/radio-group/test/lion-radio-group.test.js index 8f5b56835..fa9bd3616 100644 --- a/packages/radio-group/test/lion-radio-group.test.js +++ b/packages/radio-group/test/lion-radio-group.test.js @@ -36,6 +36,20 @@ describe('', () => { expect(el.checkedValue).to.deep.equal({ some: 'data' }); }); + it('can handle 0 and empty string as valid values ', async () => { + const el = await fixture(html` + + + + + `); + await nextFrame(); + + expect(el.checkedValue).to.equal(0); + el.formElementsArray[1].choiceChecked = true; + expect(el.checkedValue).to.equal(''); + }); + it('still has a full modelValue ', async () => { const el = await fixture(html`