mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(utils): [vnode] flattedChildren support subTree (#10298)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { nextTick, ref } from 'vue'
|
||||
import { defineComponent, nextTick, ref } from 'vue'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { describe, expect, test, vi } from 'vitest'
|
||||
import { EVENT_CODE } from '@element-plus/constants'
|
||||
@@ -8,6 +8,19 @@ import TabNav from '../src/tab-nav'
|
||||
import type { TabPaneName } from '../src/tabs'
|
||||
import type { TabsPaneContext } from '@element-plus/tokens'
|
||||
|
||||
const Comp = defineComponent({
|
||||
components: {
|
||||
TabPane,
|
||||
},
|
||||
setup() {
|
||||
return () => (
|
||||
<TabPane name="tab1" label="tab1">
|
||||
Tab 1 content
|
||||
</TabPane>
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
describe('Tabs.vue', () => {
|
||||
test('create', async () => {
|
||||
const wrapper = mount(() => (
|
||||
@@ -754,4 +767,17 @@ describe('Tabs.vue', () => {
|
||||
expect(navItemsWrapper[2].classes('is-active')).toBe(true)
|
||||
expect(navItemsWrapper[3].classes('is-active')).toBe(false)
|
||||
})
|
||||
|
||||
test('tab-pane nested', async () => {
|
||||
const wrapper = mount(() => (
|
||||
<Tabs>
|
||||
<Comp />
|
||||
</Tabs>
|
||||
))
|
||||
|
||||
const panesWrapper = wrapper.findAllComponents(TabPane)
|
||||
await nextTick()
|
||||
|
||||
expect(panesWrapper.length).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -159,6 +159,9 @@ export const flattedChildren = (
|
||||
result.push(...flattedChildren(child.children))
|
||||
} else {
|
||||
result.push(child)
|
||||
if (isVNode(child) && child.component?.subTree) {
|
||||
result.push(...flattedChildren(child.component.subTree))
|
||||
}
|
||||
}
|
||||
})
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user