fix: checkbox label auto convert to bool when label is empty (#2287) (#2380)

This commit is contained in:
msidolphin 2021-07-01 08:12:47 +08:00 committed by GitHub
parent 6050baf0b2
commit e10071a430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -125,7 +125,7 @@ describe('Checkbox', () => {
expect(vm.checkList).toEqual(['a'])
})
test('true false lable', async () => {
test('true false label', async () => {
const wrapper = _mount(
`<el-checkbox true-label="a" :false-label="3" v-model="checked"></el-checkbox>`,
() => ({
@ -155,6 +155,27 @@ describe('Checkbox', () => {
expect(wrapper.vm.checked).toBe(true)
expect(wrapper.vm.checklist).toEqual(['a'])
})
test('label', async() => {
const wrapper = _mount(
`
<div>
<el-checkbox-group v-model="checklist">
<el-checkbox label="">all</el-checkbox>
<el-checkbox label="a">a</el-checkbox>
<el-checkbox label="b">b</el-checkbox>
</el-checkbox-group>
</div>
`,
() => ({
checked: false,
checklist: [],
}),
)
const checkbox = wrapper.find('.el-checkbox')
await checkbox.trigger('click')
expect(wrapper.vm.checklist[0]).toEqual('')
})
})
describe('check-button', () => {

View File

@ -75,7 +75,7 @@ export default defineComponent({
default: () => undefined,
},
label: {
type: [Boolean, Number, String],
type: [String, Boolean, Number],
},
indeterminate: Boolean,
disabled: Boolean,