Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): [vnode] flattedChildren support subTree #10298

Merged
merged 3 commits into from Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 25 additions & 1 deletion packages/components/tabs/__tests__/tabs.test.tsx
@@ -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'
Expand All @@ -8,6 +8,17 @@ import TabNav from '../src/tab-nav'
import type { TabPaneName } from '../src/tabs'
import type { TabsPaneContext } from '@element-plus/tokens'

const Comp = defineComponent({
components: {
TabPane,
},
template: `
<TabPane name="tab1" label="tab1">
Tab 1 content
</TabPane>
`,
})

chenxch marked this conversation as resolved.
Show resolved Hide resolved
describe('Tabs.vue', () => {
test('create', async () => {
const wrapper = mount(() => (
Expand Down Expand Up @@ -754,4 +765,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)
})
})
3 changes: 3 additions & 0 deletions packages/utils/vue/vnode.ts
Expand Up @@ -159,6 +159,9 @@ export const flattedChildren = (
result.push(...flattedChildren(child.children))
} else {
result.push(child)
if (isVNode(child) && child.component && child.component.subTree) {
chenxch marked this conversation as resolved.
Show resolved Hide resolved
result.push(...flattedChildren(child.component.subTree.children))
}
}
})
return result
Expand Down