]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): detected forwarded slots in nested components (#4268)
authorfishDog <40156382+Bigfish8@users.noreply.github.com>
Sat, 7 Aug 2021 02:37:55 +0000 (10:37 +0800)
committerGitHub <noreply@github.com>
Sat, 7 Aug 2021 02:37:55 +0000 (22:37 -0400)
fix #4244

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

index bb26d668931f3e8dcfe9f5638d6018fd644dad2e..4a7df1e8dfe86ba64efadef14b27b0f42ce681c5 100644 (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', () => {
index 68aa1f67ccd523055667fcc12f470ff897c8b695..8fc86740eb6314d1d296abbe03e35bfcdae70980 100644 (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
         }