From e10071a430dcfbc6b6e2e781b479195557b10a62 Mon Sep 17 00:00:00 2001 From: msidolphin Date: Thu, 1 Jul 2021 08:12:47 +0800 Subject: [PATCH] fix: checkbox label auto convert to bool when label is empty (#2287) (#2380) --- packages/checkbox/__tests__/checkbox.spec.ts | 23 +++++++++++++++++++- packages/checkbox/src/checkbox.vue | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/checkbox/__tests__/checkbox.spec.ts b/packages/checkbox/__tests__/checkbox.spec.ts index 51c7bf070a..33eab2d81a 100644 --- a/packages/checkbox/__tests__/checkbox.spec.ts +++ b/packages/checkbox/__tests__/checkbox.spec.ts @@ -125,7 +125,7 @@ describe('Checkbox', () => { expect(vm.checkList).toEqual(['a']) }) - test('true false lable', async () => { + test('true false label', async () => { const wrapper = _mount( ``, () => ({ @@ -155,6 +155,27 @@ describe('Checkbox', () => { expect(wrapper.vm.checked).toBe(true) expect(wrapper.vm.checklist).toEqual(['a']) }) + + test('label', async() => { + const wrapper = _mount( + ` +
+ + all + a + b + +
+ `, + () => ({ + checked: false, + checklist: [], + }), + ) + const checkbox = wrapper.find('.el-checkbox') + await checkbox.trigger('click') + expect(wrapper.vm.checklist[0]).toEqual('') + }) }) describe('check-button', () => { diff --git a/packages/checkbox/src/checkbox.vue b/packages/checkbox/src/checkbox.vue index 9d5dd044b1..16419c1bd6 100644 --- a/packages/checkbox/src/checkbox.vue +++ b/packages/checkbox/src/checkbox.vue @@ -75,7 +75,7 @@ export default defineComponent({ default: () => undefined, }, label: { - type: [Boolean, Number, String], + type: [String, Boolean, Number], }, indeterminate: Boolean, disabled: Boolean,