Skip to content

Commit

Permalink
fix(compiler-core): fix forwarded slots detection on template slots (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Jul 15, 2021
1 parent 6a0c7cd commit c23153d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/compiler-core/__tests__/transforms/vSlot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,13 @@ describe('compiler: transform component slots', () => {
const { slots } = parseWithSlots(`<Comp><slot v-for="a in b"/></Comp>`)
expect(slots).toMatchObject(toMatch)
})

test('<slot> tag w/ template', () => {
const { slots } = parseWithSlots(
`<Comp><template #default><slot/></template></Comp>`
)
expect(slots).toMatchObject(toMatch)
})
})

describe('errors', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-core/src/transforms/vSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ function hasForwardedSlots(children: TemplateChildNode[]): boolean {
case NodeTypes.ELEMENT:
if (
child.tagType === ElementTypes.SLOT ||
(child.tagType === ElementTypes.ELEMENT &&
((child.tagType === ElementTypes.ELEMENT ||
child.tagType === ElementTypes.TEMPLATE) &&
hasForwardedSlots(child.children))
) {
return true
Expand Down

0 comments on commit c23153d

Please sign in to comment.