@@ -15,6 +15,7 @@ import { transformElement } from '../../src/transforms/transformElement'
15
15
import { transformOn } from '../../src/transforms/vOn'
16
16
import { transformBind } from '../../src/transforms/vBind'
17
17
import { transformExpression } from '../../src/transforms/transformExpression'
18
+ import { transformSlotOutlet } from '../../src/transforms/transformSlotOutlet'
18
19
import {
19
20
trackSlotScopes ,
20
21
trackVForSlotScopes
@@ -34,6 +35,7 @@ function parseWithSlots(template: string, options: CompilerOptions = {}) {
34
35
...( options . prefixIdentifiers
35
36
? [ trackVForSlotScopes , transformExpression ]
36
37
: [ ] ) ,
38
+ transformSlotOutlet ,
37
39
transformElement ,
38
40
trackSlotScopes
39
41
] ,
@@ -737,9 +739,8 @@ describe('compiler: transform component slots', () => {
737
739
expect ( generate ( root , { prefixIdentifiers : true } ) . code ) . toMatchSnapshot ( )
738
740
} )
739
741
740
- test ( 'generate flag on forwarded slots' , ( ) => {
741
- const { slots } = parseWithSlots ( `<Comp><slot/></Comp>` )
742
- expect ( slots ) . toMatchObject ( {
742
+ describe ( 'forwarded slots' , ( ) => {
743
+ const toMatch = {
743
744
type : NodeTypes . JS_OBJECT_EXPRESSION ,
744
745
properties : [
745
746
{
@@ -751,6 +752,20 @@ describe('compiler: transform component slots', () => {
751
752
value : { content : `3 /* FORWARDED */` }
752
753
}
753
754
]
755
+ }
756
+ test ( '<slot> tag only' , ( ) => {
757
+ const { slots } = parseWithSlots ( `<Comp><slot/></Comp>` )
758
+ expect ( slots ) . toMatchObject ( toMatch )
759
+ } )
760
+
761
+ test ( '<slot> tag w/ v-if' , ( ) => {
762
+ const { slots } = parseWithSlots ( `<Comp><slot v-if="ok"/></Comp>` )
763
+ expect ( slots ) . toMatchObject ( toMatch )
764
+ } )
765
+
766
+ test ( '<slot> tag w/ v-for' , ( ) => {
767
+ const { slots } = parseWithSlots ( `<Comp><slot v-for="a in b"/></Comp>` )
768
+ expect ( slots ) . toMatchObject ( toMatch )
754
769
} )
755
770
} )
756
771
0 commit comments