@@ -177,7 +177,7 @@ describe('component: slots', () => {
177177
178178 const { host } = define ( ( ) => {
179179 return createComponent ( Comp , null , {
180- header : ( ) => template ( 'header' ) ( ) ,
180+ header : withVaporCtx ( ( ) => template ( 'header' ) ( ) ) ,
181181 } )
182182 } ) . render ( )
183183
@@ -224,7 +224,7 @@ describe('component: slots', () => {
224224 )
225225 define ( ( ) =>
226226 createComponent ( Comp , null , {
227- default : _props => ( ( props = _props ) , [ ] ) ,
227+ default : withVaporCtx ( ( _props : any ) => ( ( props = _props ) , [ ] ) ) ,
228228 } ) ,
229229 ) . render ( )
230230
@@ -252,7 +252,7 @@ describe('component: slots', () => {
252252 )
253253 define ( ( ) =>
254254 createComponent ( Comp , null , {
255- default : _props => ( ( props = _props ) , [ ] ) ,
255+ default : withVaporCtx ( ( _props : any ) => ( ( props = _props ) , [ ] ) ) ,
256256 } ) ,
257257 ) . render ( )
258258
@@ -285,13 +285,13 @@ describe('component: slots', () => {
285285 $ : [
286286 ( ) => ( {
287287 name : 'header' ,
288- fn : ( props : any ) => {
288+ fn : withVaporCtx ( ( props : any ) => {
289289 const el = template ( '<h1></h1>' ) ( )
290290 renderEffect ( ( ) => {
291291 setElementText ( el , props . title )
292292 } )
293293 return el
294- } ,
294+ } ) ,
295295 } ) ,
296296 ] ,
297297 } )
@@ -320,8 +320,8 @@ describe('component: slots', () => {
320320
321321 const { host } = define ( ( ) => {
322322 return createComponent ( Comp , null , {
323- header : ( ) => template ( 'header' ) ( ) ,
324- footer : ( ) => template ( 'footer' ) ( ) ,
323+ header : withVaporCtx ( ( ) => template ( 'header' ) ( ) ) ,
324+ footer : withVaporCtx ( ( ) => template ( 'footer' ) ( ) ) ,
325325 } )
326326 } ) . render ( )
327327
@@ -368,8 +368,14 @@ describe('component: slots', () => {
368368 $ : [
369369 ( ) =>
370370 flag1 . value
371- ? { name : 'one' , fn : ( ) => template ( 'one content' ) ( ) }
372- : { name : 'two' , fn : ( ) => template ( 'two content' ) ( ) } ,
371+ ? {
372+ name : 'one' ,
373+ fn : withVaporCtx ( ( ) => template ( 'one content' ) ( ) ) ,
374+ }
375+ : {
376+ name : 'two' ,
377+ fn : withVaporCtx ( ( ) => template ( 'two content' ) ( ) ) ,
378+ } ,
373379 ] ,
374380 } )
375381 } ) . render ( )
@@ -413,8 +419,8 @@ describe('component: slots', () => {
413419 Child ,
414420 { } ,
415421 {
416- one : ( ) => template ( 'one content' ) ( ) ,
417- two : ( ) => template ( 'two content' ) ( ) ,
422+ one : withVaporCtx ( ( ) => template ( 'one content' ) ( ) ) ,
423+ two : withVaporCtx ( ( ) => template ( 'two content' ) ( ) ) ,
418424 } ,
419425 )
420426 } ) . render ( )
@@ -461,14 +467,14 @@ describe('component: slots', () => {
461467 const { html } = define ( {
462468 setup ( ) {
463469 return createComponent ( Child , null , {
464- default : ( ) => {
470+ default : withVaporCtx ( ( ) => {
465471 return createIf (
466472 ( ) => toggle . value ,
467473 ( ) => {
468474 return document . createTextNode ( 'content' )
469475 } ,
470476 )
471- } ,
477+ } ) ,
472478 } )
473479 } ,
474480 } ) . render ( )
@@ -498,14 +504,14 @@ describe('component: slots', () => {
498504 const { html } = define ( {
499505 setup ( ) {
500506 return createComponent ( Child , null , {
501- default : ( ) => {
507+ default : withVaporCtx ( ( ) => {
502508 return createIf (
503509 ( ) => toggle . value ,
504510 ( ) => {
505511 return document . createTextNode ( 'content' )
506512 } ,
507513 )
508- } ,
514+ } ) ,
509515 } )
510516 } ,
511517 } ) . render ( )
@@ -539,9 +545,9 @@ describe('component: slots', () => {
539545 ( toggle . value
540546 ? {
541547 name : val . value ,
542- fn : ( ) => {
548+ fn : withVaporCtx ( ( ) => {
543549 return template ( '<h1></h1>' ) ( )
544- } ,
550+ } ) ,
545551 }
546552 : void 0 ) as DynamicSlot ,
547553 ] ,
@@ -567,9 +573,9 @@ describe('component: slots', () => {
567573 const { html } = define ( {
568574 setup ( ) {
569575 return createComponent ( Child , null , {
570- default : ( ) => {
576+ default : withVaporCtx ( ( ) => {
571577 return template ( '<!--comment-->' ) ( )
572- } ,
578+ } ) ,
573579 } )
574580 } ,
575581 } ) . render ( )
@@ -591,14 +597,14 @@ describe('component: slots', () => {
591597 const { html } = define ( {
592598 setup ( ) {
593599 return createComponent ( Child , null , {
594- default : ( ) => {
600+ default : withVaporCtx ( ( ) => {
595601 return createIf (
596602 ( ) => toggle . value ,
597603 ( ) => {
598604 return document . createTextNode ( 'content' )
599605 } ,
600606 )
601- } ,
607+ } ) ,
602608 } )
603609 } ,
604610 } ) . render ( )
@@ -629,7 +635,7 @@ describe('component: slots', () => {
629635 const { html } = define ( {
630636 setup ( ) {
631637 return createComponent ( Child , null , {
632- default : ( ) => {
638+ default : withVaporCtx ( ( ) => {
633639 return createIf (
634640 ( ) => outerShow . value ,
635641 ( ) => {
@@ -641,7 +647,7 @@ describe('component: slots', () => {
641647 )
642648 } ,
643649 )
644- } ,
650+ } ) ,
645651 } )
646652 } ,
647653 } ) . render ( )
@@ -686,7 +692,7 @@ describe('component: slots', () => {
686692 const { html } = define ( {
687693 setup ( ) {
688694 return createComponent ( Child , null , {
689- default : ( ) => {
695+ default : withVaporCtx ( ( ) => {
690696 const n2 = createFor (
691697 ( ) => items . value ,
692698 for_item0 => {
@@ -699,7 +705,7 @@ describe('component: slots', () => {
699705 } ,
700706 )
701707 return n2
702- } ,
708+ } ) ,
703709 } )
704710 } ,
705711 } ) . render ( )
@@ -732,7 +738,7 @@ describe('component: slots', () => {
732738 const { html } = define ( {
733739 setup ( ) {
734740 return createComponent ( Child , null , {
735- default : ( ) => {
741+ default : withVaporCtx ( ( ) => {
736742 const n2 = createFor (
737743 ( ) => items . value ,
738744 for_item0 => {
@@ -745,7 +751,7 @@ describe('component: slots', () => {
745751 } ,
746752 )
747753 return n2
748- } ,
754+ } ) ,
749755 } )
750756 } ,
751757 } ) . render ( )
@@ -800,11 +806,11 @@ describe('component: slots', () => {
800806 Parent ,
801807 null ,
802808 {
803- foo : ( ) => {
809+ foo : withVaporCtx ( ( ) => {
804810 const n0 = template ( ' ' ) ( ) as any
805811 renderEffect ( ( ) => setText ( n0 , foo . value ) )
806812 return n0
807- } ,
813+ } ) ,
808814 } ,
809815 true ,
810816 )
@@ -845,16 +851,16 @@ describe('component: slots', () => {
845851 Parent ,
846852 null ,
847853 {
848- foo : ( ) => {
854+ foo : withVaporCtx ( ( ) => {
849855 const n0 = template ( ' ' ) ( ) as any
850856 renderEffect ( ( ) => setText ( n0 , foo . value ) )
851857 return n0
852- } ,
853- default : ( ) => {
858+ } ) ,
859+ default : withVaporCtx ( ( ) => {
854860 const n3 = template ( ' ' ) ( ) as any
855861 renderEffect ( ( ) => setText ( n3 , foo . value ) )
856862 return n3
857- } ,
863+ } ) ,
858864 } ,
859865 true ,
860866 )
@@ -893,7 +899,7 @@ describe('component: slots', () => {
893899 const { html } = define ( {
894900 setup ( ) {
895901 return createComponent ( Parent , null , {
896- default : ( ) => template ( '<!-- <div>App</div> -->' ) ( ) ,
902+ default : withVaporCtx ( ( ) => template ( '<!-- <div>App</div> -->' ) ( ) ) ,
897903 } )
898904 } ,
899905 } ) . render ( )
@@ -933,7 +939,7 @@ describe('component: slots', () => {
933939 const { html } = define ( {
934940 setup ( ) {
935941 return createComponent ( Parent , null , {
936- default : ( ) => template ( '<!-- <div>App</div> -->' ) ( ) ,
942+ default : withVaporCtx ( ( ) => template ( '<!-- <div>App</div> -->' ) ( ) ) ,
937943 } )
938944 } ,
939945 } ) . render ( )
@@ -999,6 +1005,36 @@ describe('component: slots', () => {
9991005 expect ( html ( ) ) . toBe ( 'child fallback<!--for--><!--slot--><!--slot-->' )
10001006 } )
10011007
1008+ test ( 'consecutive slots with insertion state' , async ( ) => {
1009+ const { component : Child } = define ( {
1010+ setup ( ) {
1011+ const n2 = template ( '<div><div>baz</div></div>' , true ) ( ) as any
1012+ setInsertionState ( n2 , 0 )
1013+ createSlot ( 'default' , null )
1014+ setInsertionState ( n2 , 0 )
1015+ createSlot ( 'foo' , null )
1016+ return n2
1017+ } ,
1018+ } )
1019+
1020+ const { html } = define ( {
1021+ setup ( ) {
1022+ return createComponent ( Child , null , {
1023+ default : withVaporCtx ( ( ) => template ( 'default' ) ( ) ) ,
1024+ foo : withVaporCtx ( ( ) => template ( 'foo' ) ( ) ) ,
1025+ } )
1026+ } ,
1027+ } ) . render ( )
1028+
1029+ expect ( html ( ) ) . toBe (
1030+ `<div>` +
1031+ `default<!--slot-->` +
1032+ `foo<!--slot-->` +
1033+ `<div>baz</div>` +
1034+ `</div>` ,
1035+ )
1036+ } )
1037+
10021038 describe ( 'vdom interop' , ( ) => {
10031039 const createVaporSlot = ( fallbackText = 'fallback' ) => {
10041040 return defineVaporComponent ( {
@@ -1862,35 +1898,5 @@ describe('component: slots', () => {
18621898 expect ( root . innerHTML ) . toBe ( '<span>bar</span>' )
18631899 } )
18641900 } )
1865-
1866- test ( 'consecutive slots with insertion state' , async ( ) => {
1867- const { component : Child } = define ( {
1868- setup ( ) {
1869- const n2 = template ( '<div><div>baz</div></div>' , true ) ( ) as any
1870- setInsertionState ( n2 , 0 )
1871- createSlot ( 'default' , null )
1872- setInsertionState ( n2 , 0 )
1873- createSlot ( 'foo' , null )
1874- return n2
1875- } ,
1876- } )
1877-
1878- const { html } = define ( {
1879- setup ( ) {
1880- return createComponent ( Child , null , {
1881- default : ( ) => template ( 'default' ) ( ) ,
1882- foo : ( ) => template ( 'foo' ) ( ) ,
1883- } )
1884- } ,
1885- } ) . render ( )
1886-
1887- expect ( html ( ) ) . toBe (
1888- `<div>` +
1889- `default<!--slot-->` +
1890- `foo<!--slot-->` +
1891- `<div>baz</div>` +
1892- `</div>` ,
1893- )
1894- } )
18951901 } )
18961902} )
0 commit comments