@@ -78,15 +78,11 @@ export function embed(path: FastPath, _options: Options) {
78
78
const parent : Node = path . getParentNode ( ) ;
79
79
const printJsExpression = ( ) =>
80
80
( parent as any ) . expression
81
- ? printJS (
82
- parent ,
83
- ( options . svelteStrictMode && ! options . _svelte_is5Plus ) ?? false ,
84
- false ,
85
- false ,
86
- 'expression' ,
87
- )
81
+ ? printJS ( parent , 'expression' , {
82
+ forceSingleQuote : ( options . svelteStrictMode && ! options . _svelte_is5Plus ) ?? false ,
83
+ } )
88
84
: undefined ;
89
- const printSvelteBlockJS = ( name : string ) => printJS ( parent , false , true , false , name ) ;
85
+ const printSvelteBlockJS = ( name : string ) => printJS ( parent , name , { forceSingleLine : true } ) ;
90
86
91
87
switch ( parent . type ) {
92
88
case 'IfBlock' :
@@ -116,25 +112,23 @@ export function embed(path: FastPath, _options: Options) {
116
112
}
117
113
break ;
118
114
case 'Element' :
119
- printJS (
120
- parent ,
121
- ( options . svelteStrictMode && ! options . _svelte_is5Plus ) ?? false ,
122
- false ,
123
- false ,
124
- 'tag' ,
125
- ) ;
115
+ printJS ( parent , 'tag' , {
116
+ forceSingleQuote : ( options . svelteStrictMode && ! options . _svelte_is5Plus ) ?? false ,
117
+ } ) ;
126
118
break ;
127
119
case 'MustacheTag' :
128
- printJS ( parent , isInsideQuotedAttribute ( path , options ) , false , false , 'expression' ) ;
120
+ printJS ( parent , 'expression' , {
121
+ forceSingleQuote : isInsideQuotedAttribute ( path , options ) ,
122
+ } ) ;
129
123
break ;
130
124
case 'RawMustacheTag' :
131
- printJS ( parent , false , false , false , 'expression' ) ;
125
+ printJS ( parent , 'expression' , { } ) ;
132
126
break ;
133
127
case 'Spread' :
134
- printJS ( parent , false , false , false , 'expression' ) ;
128
+ printJS ( parent , 'expression' , { } ) ;
135
129
break ;
136
130
case 'ConstTag' :
137
- printJS ( parent , false , false , true , 'expression' ) ;
131
+ printJS ( parent , 'expression' , { removeParentheses : true } ) ;
138
132
break ;
139
133
case 'RenderTag' :
140
134
if ( node === parent . expression ) {
@@ -150,7 +144,7 @@ export function embed(path: FastPath, _options: Options) {
150
144
parent . argument = null ;
151
145
parent . arguments = null ;
152
146
}
153
- printJS ( parent , false , false , false , 'expression' ) ;
147
+ printJS ( parent , 'expression' , { } ) ;
154
148
}
155
149
break ;
156
150
case 'EventHandler' :
@@ -409,17 +403,19 @@ async function embedTag(
409
403
410
404
function printJS (
411
405
node : any ,
412
- forceSingleQuote : boolean ,
413
- forceSingleLine : boolean ,
414
- removeParentheses : boolean ,
415
406
name : string ,
407
+ options : {
408
+ forceSingleQuote ?: boolean ;
409
+ forceSingleLine ?: boolean ;
410
+ removeParentheses ?: boolean ;
411
+ } ,
416
412
) {
417
413
const part = node [ name ] as BaseNode | undefined ;
418
414
if ( ! part || typeof part !== 'object' ) {
419
415
return ;
420
416
}
421
417
part . isJS = true ;
422
- part . forceSingleQuote = forceSingleQuote ;
423
- part . forceSingleLine = forceSingleLine ;
424
- part . removeParentheses = removeParentheses ;
418
+ part . forceSingleQuote = options . forceSingleQuote ;
419
+ part . forceSingleLine = options . forceSingleLine ;
420
+ part . removeParentheses = options . removeParentheses ;
425
421
}
0 commit comments