fix: [el-popover] compatible svg (#6089)

* fix: [el-popover] compatible svg

* fix: add test
This commit is contained in:
啝裳 2022-02-21 14:23:20 +08:00 committed by GitHub
parent cfc43e2a6d
commit 0b4acfbabb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -75,6 +75,36 @@ describe('<ElOnlyChild />', () => {
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 () => {
wrapper = createComponent(() => [
h(Fragment, [h(Comment, 'some comment'), AXIOM as any]),

View File

@ -64,6 +64,8 @@ function findFirstLegitChild(node: VNode[] | undefined) {
continue
case Text:
return wrapTextContent(child)
case 'svg':
return wrapTextContent(child)
case Fragment:
return findFirstLegitChild(child.children as VNode[])
default: