From: edison Date: Thu, 15 Jul 2021 15:37:11 +0000 (+0800) Subject: fix(compiler-core): fix forwarded slots detection on template slots (#4124) X-Git-Tag: v3.1.5~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c23153d82eb2aa57d254dd362a78383defec3968;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-core): fix forwarded slots detection on template slots (#4124) fix #4123 --- diff --git a/packages/compiler-core/__tests__/transforms/vSlot.spec.ts b/packages/compiler-core/__tests__/transforms/vSlot.spec.ts index beddd212ab..bb26d66893 100644 --- a/packages/compiler-core/__tests__/transforms/vSlot.spec.ts +++ b/packages/compiler-core/__tests__/transforms/vSlot.spec.ts @@ -771,6 +771,13 @@ describe('compiler: transform component slots', () => { const { slots } = parseWithSlots(``) expect(slots).toMatchObject(toMatch) }) + + test(' tag w/ template', () => { + const { slots } = parseWithSlots( + `` + ) + expect(slots).toMatchObject(toMatch) + }) }) describe('errors', () => { diff --git a/packages/compiler-core/src/transforms/vSlot.ts b/packages/compiler-core/src/transforms/vSlot.ts index 327bac448b..1e784c82b6 100644 --- a/packages/compiler-core/src/transforms/vSlot.ts +++ b/packages/compiler-core/src/transforms/vSlot.ts @@ -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