fix(compiler-core): detected forwarded slots in nested components (#4268)

fix #4244
This commit is contained in:
fishDog 2021-08-07 10:37:55 +08:00 committed by GitHub
parent a211e271ee
commit abb3a81e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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', () => {

View File

@ -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
}