@@ -26,7 +26,6 @@ import {
2626 isIgnoreEndDirective ,
2727 isIgnoreStartDirective ,
2828 isInlineElement ,
29- isInsideQuotedAttribute ,
3029 isLoneMustacheTag ,
3130 isNodeSupportedLanguage ,
3231 isNodeTopLevelHTML ,
@@ -89,7 +88,8 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
8988 return printTopLevelParts ( n , options , path , print ) ;
9089 }
9190
92- const [ open , close ] = options . svelteStrictMode ? [ '"{' , '}"' ] : [ '{' , '}' ] ;
91+ const [ open , close ] =
92+ options . svelteStrictMode && ! options . _svelte_is5Plus ? [ '"{' , '}"' ] : [ '{' , '}' ] ;
9393 const printJsExpression = ( ) => [ open , printJS ( path , print , 'expression' ) , close ] ;
9494 const node = n as Node ;
9595
@@ -438,18 +438,17 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
438438 if ( isOrCanBeConvertedToShorthand ( node ) ) {
439439 if ( options . svelteAllowShorthand ) {
440440 return [ '{' , node . name , '}' ] ;
441- } else if ( options . svelteStrictMode ) {
442- return [ node . name , '="{' , node . name , '}"' ] ;
443441 } else {
444- return [ node . name , '={' , node . name , '}' ] ;
442+ return [ node . name , `= ${ open } ` , node . name , close ] ;
445443 }
446444 } else {
447445 if ( node . value === true ) {
448446 return [ node . name ] ;
449447 }
450448
451449 const quotes =
452- ! isLoneMustacheTag ( node . value ) || ( options . svelteStrictMode ?? false ) ;
450+ ! isLoneMustacheTag ( node . value ) ||
451+ ( ( options . svelteStrictMode && ! options . _svelte_is5Plus ) ?? false ) ;
453452 const attrNodeValue = printAttributeNodeValue ( path , print , quotes , node ) ;
454453 if ( quotes ) {
455454 return [ node . name , '=' , '"' , attrNodeValue , '"' ] ;
@@ -649,14 +648,13 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
649648 if ( isOrCanBeConvertedToShorthand ( node ) || node . value === true ) {
650649 if ( options . svelteAllowShorthand ) {
651650 return [ ...prefix ] ;
652- } else if ( options . svelteStrictMode ) {
653- return [ ...prefix , '="{' , node . name , '}"' ] ;
654651 } else {
655- return [ ...prefix , '={' , node . name , '}' ] ;
652+ return [ ...prefix , `= ${ open } ` , node . name , close ] ;
656653 }
657654 } else {
658655 const quotes =
659- ! isLoneMustacheTag ( node . value ) || ( options . svelteStrictMode ?? false ) ;
656+ ! isLoneMustacheTag ( node . value ) ||
657+ ( ( options . svelteStrictMode && ! options . _svelte_is5Plus ) ?? false ) ;
660658 const attrNodeValue = printAttributeNodeValue ( path , print , quotes , node ) ;
661659 if ( quotes ) {
662660 return [ ...prefix , '=' , '"' , attrNodeValue , '"' ] ;
0 commit comments