File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1
1
<script lang="tsx" setup>
2
2
import { ref } from ' vue'
3
3
import For from ' ./for.vue'
4
+ import Bind from ' ./bind.vue'
4
5
5
6
const count = ref (1 )
6
7
function Comp({ icon , getChildren }: any , { slots }: any ) {
@@ -111,6 +112,11 @@ defineRender((
111
112
<Comp3 />
112
113
<Comp4 />
113
114
115
+ <div >
116
+ v-bind:
117
+ <Bind />
118
+ </div >
119
+
114
120
<div >
115
121
v-show:
116
122
<span v-show = { count .value } >
Original file line number Diff line number Diff line change
1
+ <script setup lang="tsx">
2
+ import { ref } from ' vue'
3
+
4
+ function Comp(props : any ) {
5
+ return (
6
+ <span >
7
+ { props }
8
+ </span >
9
+ )
10
+ }
11
+
12
+ const count = ref (0 )
13
+ defineRender (
14
+ <Comp
15
+ id = { 1 }
16
+ v-model :value = { count .value }
17
+ { ... { id: 2 }}
18
+ { ... {
19
+ id: 3 ,
20
+ }}
21
+ />,
22
+ )
23
+ </script >
Original file line number Diff line number Diff line change @@ -68,8 +68,11 @@ export function transformVueJsxVapor(
68
68
) {
69
69
s . appendLeft ( node . end ! - 1 , 'template' )
70
70
}
71
- else if ( node . type === 'JSXSpreadAttribute' ) {
72
- s . appendLeft ( node . start ! , 'v-bind=' )
71
+ else if ( node . type === 'JSXSpreadAttribute' && parent ?. type === 'JSXOpeningElement' ) {
72
+ const index = parent . attributes
73
+ . filter ( attr => attr . type === 'JSXSpreadAttribute' )
74
+ . findIndex ( attr => attr === node )
75
+ s . appendLeft ( node . start ! , `${ index ? `:v${ index } ` : 'v' } -bind=` )
73
76
s . overwrite ( node . start ! , node . argument . start ! , '"' )
74
77
s . overwrite ( node . end ! - 1 , node . end ! , '"' )
75
78
}
@@ -159,6 +162,7 @@ export function transformVueJsxVapor(
159
162
code = code
160
163
. replace ( '_cache' , '_cache = []' )
161
164
. replaceAll ( / _ c t x \. (? ! \$ s l o t s ) / g, '' )
165
+ . replaceAll ( / { " v \d + \- b i n d " : ( [ \s \S ] * ) } / g, '$1' )
162
166
. replaceAll ( / _ r e s o l v e C o m p o n e n t \( " ( .* ) " \) / g, ( $0 , $1 ) => `(() => { try { return ${ $1 } } catch { return ${ $0 } } })()` )
163
167
return runtime === '"vue"' ? `(${ code } )()` : code
164
168
}
You can’t perform that action at this time.
0 commit comments