Skip to content

Commit

Permalink
fix(compiler-core): detected forwarded slots in nested components (#4268
Browse files Browse the repository at this point in the history
)

fix #4244
  • Loading branch information
Bigfish8 authored Aug 7, 2021
1 parent a211e27 commit abb3a81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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 @@ -778,6 +778,13 @@ describe('compiler: transform component slots', () => {
)
expect(slots).toMatchObject(toMatch)
})

test('<slot w/ nested component>', () => {
const { slots } = parseWithSlots(
`<Comp><Comp><slot/></Comp></Comp>`
)
expect(slots).toMatchObject(toMatch)
})
})

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

0 comments on commit abb3a81

Please sign in to comment.