Skip to content

Commit ea1269f

Browse files
committed
chore(compat): make tabs properly filter in Vue 3
* correctly handle `null` inside children * fix test
1 parent 543b9f5 commit ea1269f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/components/tabs/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export const BTabs = /*#__PURE__*/ Vue.extend({
357357
},
358358
getTabs() {
359359
const $tabs = this.registeredTabs.filter(
360-
$tab => $tab.$children.filter($t => $t._isTab).length === 0
360+
$tab => $tab.$children.filter($t => $t && $t._isTab).length === 0
361361
)
362362

363363
// DOM Order of Tabs

src/components/tabs/tabs.spec.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ describe('tabs', () => {
3535
it('has correct card classes when prop card is true', async () => {
3636
const wrapper = mount(BTabs, {
3737
propsData: { card: true },
38-
slots: { default: [BTab, BTab, BTab] }
38+
slots: {
39+
default: {
40+
components: { BTab },
41+
template: '<div><b-tab /><b-tab /><b-tab /></div>'
42+
}
43+
}
3944
})
4045

4146
await waitNT(wrapper.vm)
@@ -55,7 +60,12 @@ describe('tabs', () => {
5560
it('has correct card classes when props card and vertical are true', async () => {
5661
const wrapper = mount(BTabs, {
5762
propsData: { card: true, vertical: true },
58-
slots: { default: [BTab, BTab, BTab] }
63+
slots: {
64+
default: {
65+
components: { BTab },
66+
template: '<div><b-tab /><b-tab /><b-tab /></div>'
67+
}
68+
}
5969
})
6070

6171
await waitNT(wrapper.vm)
@@ -84,7 +94,12 @@ describe('tabs', () => {
8494
const tabIndex = 1
8595
const wrapper = mount(BTabs, {
8696
propsData: { value: tabIndex },
87-
slots: { default: [BTab, BTab, BTab] }
97+
slots: {
98+
default: {
99+
components: { BTab },
100+
template: '<div><b-tab /><b-tab /><b-tab /></div>'
101+
}
102+
}
88103
})
89104

90105
await waitNT(wrapper.vm)

0 commit comments

Comments
 (0)