Skip to content

Commit

Permalink
fix: should use fallback for scoped slots with single falsy v-if
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and kiku-jw committed Jun 18, 2019
1 parent 2f4cfc4 commit 7d5bf48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/vdom/helpers/normalize-scoped-slots.js
Expand Up @@ -60,8 +60,10 @@ function normalizeScopedSlot(normalSlots, key, fn) {
res = res && typeof res === 'object' && !Array.isArray(res)
? [res] // single vnode
: normalizeChildren(res)
return res && res.length === 0
? undefined
return res && (
res.length === 0 ||
(res.length === 1 && res[0].isComment) // #9658
) ? undefined
: res
}
// this is a slot using the new v-slot syntax without scope. although it is
Expand Down
13 changes: 13 additions & 0 deletions test/unit/features/component/component-scoped-slot.spec.js
Expand Up @@ -1264,4 +1264,17 @@ describe('Component scoped slot', () => {
expect(vm.$el.textContent).toMatch(`Content:ok`)
}).then(done)
})

//#9658
it('fallback for scoped slot with single v-if', () => {
const vm = new Vue({
template: `<test v-slot><template v-if="false">hi</template></test>`,
components: {
Test: {
template: `<div><slot>fallback</slot></div>`
}
}
}).$mount()
expect(vm.$el.textContent).toMatch('fallback')
})
})

0 comments on commit 7d5bf48

Please sign in to comment.