File tree 3 files changed +31
-4
lines changed
3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -400,7 +400,8 @@ Beautifier.prototype.beautify = function() {
400
400
}
401
401
}
402
402
} else if ( this . _ch === '"' || this . _ch === '\'' ) {
403
- this . preserveSingleSpace ( isAfterSpace ) ;
403
+ var preserveQuoteSpace = previous_ch === '"' || previous_ch === '\'' ;
404
+ this . preserveSingleSpace ( preserveQuoteSpace || isAfterSpace ) ;
404
405
this . print_string ( this . _ch + this . eatString ( this . _ch ) ) ;
405
406
this . eatWhitespace ( true ) ;
406
407
} else if ( this . _ch === ';' ) {
@@ -507,7 +508,7 @@ Beautifier.prototype.beautify = function() {
507
508
this . _ch = '' ;
508
509
}
509
510
} else if ( this . _ch === '!' && ! this . _input . lookBack ( "\\" ) ) { // !important
510
- this . print_string ( ' ' ) ;
511
+ this . _output . space_before_token = true ;
511
512
this . print_string ( this . _ch ) ;
512
513
} else {
513
514
var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'' ;
Original file line number Diff line number Diff line change @@ -422,7 +422,8 @@ def beautify(self):
422
422
# pseudo-element
423
423
self .print_string (":" )
424
424
elif self ._ch == '"' or self ._ch == "'" :
425
- self .preserveSingleSpace (isAfterSpace )
425
+ preserveQuoteSpace = previous_ch == '"' or previous_ch == "'"
426
+ self .preserveSingleSpace (preserveQuoteSpace or isAfterSpace )
426
427
self .print_string (self ._ch + self .eatString (self ._ch ))
427
428
self .eatWhitespace (True )
428
429
elif self ._ch == ";" :
@@ -537,7 +538,7 @@ def beautify(self):
537
538
self ._ch = ""
538
539
elif self ._ch == "!" and not (self ._input .lookBack ("\\ " )):
539
540
# !important
540
- self .print_string ( " " )
541
+ self ._output . space_before_token = True
541
542
self .print_string (self ._ch )
542
543
else :
543
544
preserveAfterSpace = previous_ch == '"' or previous_ch == "'"
Original file line number Diff line number Diff line change @@ -1502,6 +1502,31 @@ exports.test_data = {
1502
1502
' filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);' ,
1503
1503
'}'
1504
1504
]
1505
+ } , {
1506
+ comment : "#2056 - Extra space before !important added" ,
1507
+ unchanged : [
1508
+ '.x {' ,
1509
+ ' $d: a !default;' ,
1510
+ '}'
1511
+ ]
1512
+ } , {
1513
+ unchanged : [
1514
+ '.x {' ,
1515
+ ' $d: a !default;' ,
1516
+ ' @if $x !=0 {' ,
1517
+ ' color: $var !important;' ,
1518
+ ' }' ,
1519
+ '}'
1520
+ ]
1521
+ } , {
1522
+ comment : "#2051 - css format removes space after quoted value" ,
1523
+ unchanged : [
1524
+ 'q {' ,
1525
+ ' quotes: \\\'"\\\' \\\'"\\\' "\\\'" "\\\'";' ,
1526
+ ' quotes: "some" \\\'thing\\\' "different";' ,
1527
+ ' quotes: \\\'some\\\' "thing" \\\'different\\\';' ,
1528
+ '}'
1529
+ ]
1505
1530
} ]
1506
1531
} , {
1507
1532
name : "Regression tests - with default options" ,
You can’t perform that action at this time.
0 commit comments