diff --git a/src/tab/index.js b/src/tab/index.js index 892f798c2..9a3e40dd5 100644 --- a/src/tab/index.js +++ b/src/tab/index.js @@ -55,9 +55,15 @@ export default createComponent({ render(h) { const { slots, parent, isActive } = this; - const shouldRender = this.inited || parent.scrollspy || !parent.lazyRender; + const slotContent = slots(); + + if (!slotContent) { + return; + } + const show = parent.scrollspy || isActive; - const Content = shouldRender ? slots() : h(); + const shouldRender = this.inited || parent.scrollspy || !parent.lazyRender; + const Content = shouldRender ? slotContent : h(); if (parent.animated) { return ( diff --git a/src/tab/test/__snapshots__/index.spec.js.snap b/src/tab/test/__snapshots__/index.spec.js.snap index 93627890c..0377c7d10 100644 --- a/src/tab/test/__snapshots__/index.spec.js.snap +++ b/src/tab/test/__snapshots__/index.spec.js.snap @@ -202,6 +202,22 @@ exports[`name prop 1`] = ` `; +exports[`render empty tab 1`] = ` +
+
+
+ + +
+
+
+
+ + +
+
+`; + exports[`render nav-left & nav-right slot 1`] = `
diff --git a/src/tab/test/index.spec.js b/src/tab/test/index.spec.js index 9eb51fba5..7e8e21054 100644 --- a/src/tab/test/index.spec.js +++ b/src/tab/test/index.spec.js @@ -410,3 +410,16 @@ test('before-change prop', async () => { expect(onChange).toHaveBeenCalledTimes(2); expect(onChange).toHaveBeenLastCalledWith(4, 'title5'); }); + +test('render empty tab', async () => { + const wrapper = mount({ + template: ` + + + + + `, + }); + + expect(wrapper).toMatchSnapshot(); +});