1
1
// @ts -check
2
2
import {
3
3
children ,
4
- createSlot ,
4
+ createComponent ,
5
+ createSlots ,
5
6
defineComponent ,
6
7
getCurrentInstance ,
7
8
insert ,
8
9
on ,
9
10
ref ,
10
- render as renderComponent ,
11
11
renderEffect ,
12
12
setText ,
13
13
template ,
@@ -27,29 +27,31 @@ const t1 = template(
27
27
28
28
const Parent = defineComponent ( {
29
29
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
+ } ) ( )
53
55
} ,
54
56
} )
55
57
@@ -59,41 +61,30 @@ const t2 = template(
59
61
60
62
const Child = defineComponent ( {
61
63
vapor : true ,
62
- props : undefined ,
63
- setup ( props , { expose : __expose } ) {
64
+ setup ( _ , { expose : __expose } ) {
64
65
__expose ( )
65
66
const message = ref ( 'Hello World!' )
66
67
function changeMessage ( ) {
67
68
message . value += '!'
68
69
}
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
79
70
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
+ } ) ( )
97
88
} ,
98
89
} )
99
90
0 commit comments