mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
fix: [el-popover] compatible svg (#6089)
* fix: [el-popover] compatible svg * fix: add test
This commit is contained in:
parent
cfc43e2a6d
commit
0b4acfbabb
@ -75,6 +75,36 @@ describe('<ElOnlyChild />', () => {
|
|||||||
expect(wrapper.find('span').exists()).toBe(true)
|
expect(wrapper.find('span').exists()).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should skip svg and child type is svg', async () => {
|
||||||
|
const wrapper = createComponent(() => [
|
||||||
|
h(
|
||||||
|
'svg',
|
||||||
|
{
|
||||||
|
xmlns: 'http://www.w3.org/2000/svg',
|
||||||
|
viewBox: '0 0 32 32',
|
||||||
|
width: '20',
|
||||||
|
height: '20',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => [
|
||||||
|
h('path', {
|
||||||
|
d: 'M14.667 14.667v-8h2.667v8h8v2.667h-8v8h-2.667v-8h-8v-2.667z',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
),
|
||||||
|
])
|
||||||
|
await nextTick()
|
||||||
|
|
||||||
|
expect(debugWarn).not.toHaveBeenCalled()
|
||||||
|
expect(wrapper.find('svg').attributes('viewBox')).toEqual('0 0 32 32')
|
||||||
|
expect(wrapper.find('svg').attributes('width')).toEqual('20')
|
||||||
|
expect(wrapper.find('svg').attributes('height')).toEqual('20')
|
||||||
|
|
||||||
|
await wrapper.trigger('hover')
|
||||||
|
await expect(wrapper.find('svg').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
it('should skip comment', async () => {
|
it('should skip comment', async () => {
|
||||||
wrapper = createComponent(() => [
|
wrapper = createComponent(() => [
|
||||||
h(Fragment, [h(Comment, 'some comment'), AXIOM as any]),
|
h(Fragment, [h(Comment, 'some comment'), AXIOM as any]),
|
||||||
|
@ -64,6 +64,8 @@ function findFirstLegitChild(node: VNode[] | undefined) {
|
|||||||
continue
|
continue
|
||||||
case Text:
|
case Text:
|
||||||
return wrapTextContent(child)
|
return wrapTextContent(child)
|
||||||
|
case 'svg':
|
||||||
|
return wrapTextContent(child)
|
||||||
case Fragment:
|
case Fragment:
|
||||||
return findFirstLegitChild(child.children as VNode[])
|
return findFirstLegitChild(child.children as VNode[])
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user