fix #9452
@@ -33,10 +33,13 @@ export function normalizeScopedSlots (
function normalizeScopedSlot(fn: Function): Function {
return scope => {
- const res = fn(scope)
- return res && typeof res === 'object' && !Array.isArray(res)
+ let res = fn(scope)
+ res = res && typeof res === 'object' && !Array.isArray(res)
? [res] // single vnode
: normalizeChildren(res)
+ return res && res.length === 0
+ ? undefined
+ : res
}
@@ -1034,4 +1034,29 @@ describe('Component scoped slot', () => {
expect(vm.$el.textContent).toBe(JSON.stringify({ changed: 'hello' }, null, 2))
}).then(done)
})
+
+ // #9452
+ it('fallback for scoped slots passed multiple levels down', () => {
+ const inner = {
+ template: `<div><slot>fallback</slot></div>`
+ }
+ const wrapper = {
+ template: `
+ <inner>
+ <template #default>
+ <slot/>
+ </template>
+ </inner>
+ `,
+ components: { inner }
+ const vm = new Vue({
+ components: { wrapper, inner },
+ template: `<wrapper/>`
+ }).$mount()
+ expect(vm.$el.textContent).toBe(`fallback`)
+ })