File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed
tests/frameworks/vue/v-bind Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -680,21 +680,19 @@ export class PugPrinter {
680680 ) : Promise < string > {
681681 const { trimTrailingSemicolon = false , trimLeadingSemicolon = true } =
682682 formatOptions ;
683- val = val . trim ( ) ;
684683 const options : Options = { ...this . codeInterpolationOptions } ;
684+
685+ val = val . trim ( ) ;
685686 const wasQuoted : boolean = isQuoted ( val ) ;
687+
686688 if ( wasQuoted ) {
687689 options . singleQuote = ! this . options . pugSingleQuote ;
688690 val = val . slice ( 1 , - 1 ) ; // Remove quotes
689691 }
690692
691693 val = await format ( val , { parser, ...options } ) ;
692- val =
693- this . quotes === '"'
694- ? // Escape double quotes, but only if they are not already escaped
695- val . replaceAll ( / (?< ! \\ ) ( (?: \\ \\ ) * ) " / g, '$1\\"' )
696- : val . replaceAll ( "'" , "\\'" ) ;
697694 val = unwrapLineFeeds ( val ) ;
695+
698696 if ( trimTrailingSemicolon && val . at ( - 1 ) === ';' ) {
699697 val = val . slice ( 0 , - 1 ) ;
700698 }
@@ -703,7 +701,17 @@ export class PugPrinter {
703701 val = val . slice ( 1 ) ;
704702 }
705703
706- return wasQuoted ? this . quoteString ( val ) : val ;
704+ if ( wasQuoted ) {
705+ val =
706+ this . quotes === '"'
707+ ? // Escape double quotes, but only if they are not already escaped
708+ ( val = val . replaceAll ( / (?< ! \\ ) ( (?: \\ \\ ) * ) " / g, '$1\\"' ) )
709+ : ( val = val . replaceAll ( "'" , "\\'" ) ) ;
710+
711+ val = this . quoteString ( val ) ;
712+ }
713+
714+ return val ;
707715 }
708716
709717 private async formatStyleAttribute ( val : string ) : Promise < string > {
Original file line number Diff line number Diff line change @@ -2,3 +2,8 @@ a(v-bind="{ ...$attrs }") ...
22a( v-bind:href ="url" ) ...
33a( :href ="url" ) ...
44a( :[key] ="url" ) ...
5+
6+ div( :value =attributes[" data-value" ])
7+ div( :value =attributes[' "data-value"' ])
8+ div( :value =attributes[" \" 'data-value'\" " ])
9+ div( :value ="\"\' data-value\'\" " )
Original file line number Diff line number Diff line change @@ -2,3 +2,8 @@ a(v-bind="{ ...$attrs }") ...
22a( v-bind:href =" url " ) ...
33a( :href =" url " ) ...
44a( :[key] =" url " ) ...
5+
6+ div( :value =attributes[' data-value' ])
7+ div( :value =attributes[' "data-value"' ])
8+ div( :value =attributes[' "\' data-value\' "' ])
9+ div( :value ='"\' data-value\' "' )
You can’t perform that action at this time.
0 commit comments