11// @ts -check
22import {
33 children ,
4- createSlot ,
4+ createComponent ,
5+ createSlots ,
56 defineComponent ,
67 getCurrentInstance ,
78 insert ,
89 on ,
910 ref ,
10- render as renderComponent ,
1111 renderEffect ,
1212 setText ,
1313 template ,
@@ -27,29 +27,31 @@ const t1 = template(
2727
2828const Parent = defineComponent ( {
2929 vapor : true ,
30- props : undefined ,
31- setup ( props ) { } ,
32- render ( _ctx ) {
33- const n0 = /** @type {any } */ ( t0 ( ) )
34- const s0 = createSlot ( {
35- mySlot : scope => {
36- const n1 = t1 ( )
37- const n2 = /** @type {any } */ ( children ( n1 , 0 ) )
38- const n3 = /** @type {any } */ ( children ( n1 , 1 ) )
39- renderEffect ( ( ) => {
40- setText ( n2 , scope . message )
41- } )
42- on ( n3 , 'click' , scope . changeMessage )
43- return [ n1 ]
44- } ,
45- // e.g. default slot
46- // default: () => {
47- // const n1 = t1()
48- // return [n1]
49- // }
50- } )
51- renderComponent ( Child , { } , s0 , n0 )
52- return n0
30+
31+ setup ( props ) {
32+ return ( ( ) => {
33+ const n0 = /** @type {any } */ ( t0 ( ) )
34+ const s0 = createSlots ( {
35+ mySlot : scope => {
36+ const n1 = t1 ( )
37+ const n2 = /** @type {any } */ ( children ( n1 , 0 ) )
38+ const n3 = /** @type {any } */ ( children ( n1 , 1 ) )
39+ renderEffect ( ( ) => {
40+ setText ( n2 , scope . message ( ) )
41+ } )
42+ on ( n3 , 'click' , scope . changeMessage )
43+ return [ n1 ]
44+ } ,
45+ // e.g. default slot
46+ // default: () => {
47+ // const n1 = t1()
48+ // return [n1]
49+ // }
50+ } )
51+ /** @type {any } */
52+ const n1 = createComponent ( Child , { } , s0 )
53+ return [ n0 , n1 ]
54+ } ) ( )
5355 } ,
5456} )
5557
@@ -59,41 +61,30 @@ const t2 = template(
5961
6062const Child = defineComponent ( {
6163 vapor : true ,
62- props : undefined ,
63- setup ( props , { expose : __expose } ) {
64+ setup ( _ , { expose : __expose } ) {
6465 __expose ( )
6566 const message = ref ( 'Hello World!' )
6667 function changeMessage ( ) {
6768 message . value += '!'
6869 }
69- const __returned__ = { message, changeMessage }
70- Object . defineProperty ( __returned__ , '__isScriptSetup' , {
71- enumerable : false ,
72- value : true ,
73- } )
74- return __returned__
75- } ,
76- render ( _ctx ) {
77- const instance = /** @type {any } */ ( getCurrentInstance ( ) )
78- const { slots } = instance
7970
80- // <div>
81- // <slot name="mySlot" :message="msg" :changeMessage="changeMessage" />
82- // <button @click="changeMessage">button in child</button>
83- // </ div>
84- const n0 = /** @type { any } */ ( t2 ( ) )
85- const n1 = /** @type { any } */ ( children ( n0 , 0 ) )
86- on ( n1 , 'click' , _ctx . changeMessage )
87- const s0 = slots . mySlot ( {
88- get message ( ) {
89- return _ctx . message
90- } ,
91- get changeMessage ( ) {
92- return _ctx . changeMessage
93- } ,
94- } )
95- insert ( s0 , n0 , n1 )
96- return n0
71+ return ( ( ) => {
72+ const instance = /** @type { any } */ ( getCurrentInstance ( ) )
73+ const { slots } = instance
74+ // <div>
75+ // <slot name="mySlot" :message="msg" :changeMessage="changeMessage" />
76+ // <button @click="changeMessage">button in child</button>
77+ // </div>
78+ const n0 = /** @type { any } */ ( t2 ( ) )
79+ const n1 = /** @type { any } */ ( children ( n0 , 0 ) )
80+ on ( n1 , 'click' , ( ) => changeMessage )
81+ const s0 = slots . mySlot ( {
82+ message : ( ) => message . value ,
83+ changeMessage : ( ) => changeMessage ,
84+ } )
85+ insert ( s0 , n0 , n1 )
86+ return n0
87+ } ) ( )
9788 } ,
9889} )
9990
0 commit comments