Skip to content

Commit

Permalink
fix(v-slot): fix scoped slot normalization combined with v-if
Browse files Browse the repository at this point in the history
Fix #12102
  • Loading branch information
posva committed Jun 2, 2021
1 parent 67901e7 commit 0367ddf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/vdom/helpers/normalize-scoped-slots.js
Expand Up @@ -64,7 +64,7 @@ function normalizeScopedSlot(normalSlots, key, fn) {
let vnode: VNode = res && res[0]
return res && (
!vnode ||
(vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391
(res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391
) ? undefined
: res
}
Expand Down
14 changes: 14 additions & 0 deletions test/unit/features/component/component-slot.spec.js
Expand Up @@ -986,4 +986,18 @@ describe('Component slot', () => {
expect(vm.$el.firstChild.innerHTML).toBe('<span><b>2</b></span>')
}).then(done)
})

// #12102
it('v-if inside scoped slot', () => {
const vm = new Vue({
template: `<test><template #custom><span v-if="false">a</span><span>b</span></template></test>`,
components: {
test: {
template: `<div><slot name="custom"/></div>`
}
}
}).$mount()

expect(vm.$el.innerHTML).toBe(`<!----><span>b</span>`)
})
})

0 comments on commit 0367ddf

Please sign in to comment.