]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): fix forwarded slots detection on template slots (#4124)
authoredison <daiwei521@126.com>
Thu, 15 Jul 2021 15:37:11 +0000 (23:37 +0800)
committerGitHub <noreply@github.com>
Thu, 15 Jul 2021 15:37:11 +0000 (11:37 -0400)
fix #4123

packages/compiler-core/__tests__/transforms/vSlot.spec.ts
packages/compiler-core/src/transforms/vSlot.ts

index beddd212ab942add4059489f06890bfa9d8b2ad2..bb26d668931f3e8dcfe9f5638d6018fd644dad2e 100644 (file)
@@ -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', () => {
index 327bac448b85166cdbafd18d75fa660fc64427a7..1e784c82b6a28d5a5d8de45d5dfc63cd2afe21df 100644 (file)
@@ -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