@@ -78,15 +78,11 @@ export function embed(path: FastPath, _options: Options) {
7878 const parent : Node = path . getParentNode ( ) ;
7979 const printJsExpression = ( ) =>
8080 ( 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+ } )
8884 : undefined ;
89- const printSvelteBlockJS = ( name : string ) => printJS ( parent , false , true , false , name ) ;
85+ const printSvelteBlockJS = ( name : string ) => printJS ( parent , name , { forceSingleLine : true } ) ;
9086
9187 switch ( parent . type ) {
9288 case 'IfBlock' :
@@ -116,25 +112,23 @@ export function embed(path: FastPath, _options: Options) {
116112 }
117113 break ;
118114 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+ } ) ;
126118 break ;
127119 case 'MustacheTag' :
128- printJS ( parent , isInsideQuotedAttribute ( path , options ) , false , false , 'expression' ) ;
120+ printJS ( parent , 'expression' , {
121+ forceSingleQuote : isInsideQuotedAttribute ( path , options ) ,
122+ } ) ;
129123 break ;
130124 case 'RawMustacheTag' :
131- printJS ( parent , false , false , false , 'expression' ) ;
125+ printJS ( parent , 'expression' , { } ) ;
132126 break ;
133127 case 'Spread' :
134- printJS ( parent , false , false , false , 'expression' ) ;
128+ printJS ( parent , 'expression' , { } ) ;
135129 break ;
136130 case 'ConstTag' :
137- printJS ( parent , false , false , true , 'expression' ) ;
131+ printJS ( parent , 'expression' , { removeParentheses : true } ) ;
138132 break ;
139133 case 'RenderTag' :
140134 if ( node === parent . expression ) {
@@ -150,7 +144,7 @@ export function embed(path: FastPath, _options: Options) {
150144 parent . argument = null ;
151145 parent . arguments = null ;
152146 }
153- printJS ( parent , false , false , false , 'expression' ) ;
147+ printJS ( parent , 'expression' , { } ) ;
154148 }
155149 break ;
156150 case 'EventHandler' :
@@ -409,17 +403,19 @@ async function embedTag(
409403
410404function printJS (
411405 node : any ,
412- forceSingleQuote : boolean ,
413- forceSingleLine : boolean ,
414- removeParentheses : boolean ,
415406 name : string ,
407+ options : {
408+ forceSingleQuote ?: boolean ;
409+ forceSingleLine ?: boolean ;
410+ removeParentheses ?: boolean ;
411+ } ,
416412) {
417413 const part = node [ name ] as BaseNode | undefined ;
418414 if ( ! part || typeof part !== 'object' ) {
419415 return ;
420416 }
421417 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 ;
425421}
0 commit comments