@@ -14,8 +14,8 @@ export function genSetText(
14
14
context : CodegenContext ,
15
15
) : CodeFragment [ ] {
16
16
const { helper } = context
17
- const { element, values, generated } = oper
18
- const texts = combineValues ( values , context )
17
+ const { element, values, generated, jsx } = oper
18
+ const texts = combineValues ( values , context , jsx )
19
19
return [
20
20
NEWLINE ,
21
21
...genCall ( helper ( 'setText' ) , `${ generated ? 'x' : 'n' } ${ element } ` , texts ) ,
@@ -27,29 +27,30 @@ export function genCreateTextNode(
27
27
context : CodegenContext ,
28
28
) : CodeFragment [ ] {
29
29
const { helper } = context
30
- const { id, values } = oper
30
+ const { id, values, jsx } = oper
31
31
return [
32
32
NEWLINE ,
33
33
`const n${ id } = ` ,
34
34
...genCall (
35
35
helper ( 'createTextNode' ) ,
36
- values && combineValues ( values , context ) ,
36
+ values && combineValues ( values , context , jsx ) ,
37
37
) ,
38
38
]
39
39
}
40
40
41
41
function combineValues (
42
42
values : SimpleExpressionNode [ ] ,
43
43
context : CodegenContext ,
44
+ jsx ?: boolean ,
44
45
) : CodeFragment [ ] {
45
46
return values . flatMap ( ( value , i ) => {
46
47
let exp = genExpression ( value , context )
47
- if ( getLiteralExpressionValue ( value ) == null ) {
48
+ if ( ! jsx && getLiteralExpressionValue ( value ) == null ) {
48
49
// dynamic, wrap with toDisplayString
49
50
exp = genCall ( context . helper ( 'toDisplayString' ) , exp )
50
51
}
51
52
if ( i > 0 ) {
52
- exp . unshift ( ' + ' )
53
+ exp . unshift ( jsx ? ', ' : ' + ' )
53
54
}
54
55
return exp
55
56
} )
0 commit comments