mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [button] space is not added (#6361)
This commit is contained in:
@@ -206,4 +206,19 @@ describe('Button Group', () => {
|
||||
'el-button__text--expand'
|
||||
)
|
||||
})
|
||||
|
||||
it('add space between two Chinese characters even if there is whitespace at both ends', async () => {
|
||||
const wrapper = mount(Button, {
|
||||
slots: {
|
||||
default: ' 中文 ',
|
||||
},
|
||||
props: {
|
||||
autoInsertSpace: true,
|
||||
},
|
||||
})
|
||||
expect(wrapper.find('.el-button span').text()).toBe('中文')
|
||||
expect(wrapper.find('.el-button span').classes()).toContain(
|
||||
'el-button__text--expand'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -77,8 +77,8 @@ const shouldAddSpace = computed(() => {
|
||||
if (autoInsertSpace.value && defaultSlot?.length === 1) {
|
||||
const slot = defaultSlot[0]
|
||||
if (slot?.type === Text) {
|
||||
const text = slot.children
|
||||
return /^\p{Unified_Ideograph}{2}$/u.test(text as string)
|
||||
const text = slot.children as string
|
||||
return /^\p{Unified_Ideograph}{2}$/u.test(text.trim())
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user