File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -500,6 +500,18 @@ Beautifier.prototype.beautify = function() {
500500 } else {
501501 this . _output . space_before_token = true ;
502502 }
503+ } else if ( ( this . _ch === '>' || this . _ch === '<' ) && parenLevel > 0 && this . _input . peek ( ) === '=' ) {
504+ // Media query range operator: >= or <=
505+ // Ensure a single space before and after the operator
506+ this . _output . space_before_token = true ;
507+ this . print_string ( this . _ch ) ;
508+ this . _input . next ( ) ; // consume '='
509+ this . print_string ( '=' ) ;
510+ this . eatWhitespace ( ) ;
511+ this . _output . space_before_token = true ;
512+ if ( whitespaceChar . test ( this . _ch ) ) {
513+ this . _ch = '' ;
514+ }
503515 } else if ( ( this . _ch === '>' || this . _ch === '+' || this . _ch === '~' ) && ! insidePropertyValue && parenLevel === 0 ) {
504516 //handle combinator spacing
505517 if ( this . _options . space_around_combinator ) {
Original file line number Diff line number Diff line change @@ -519,6 +519,21 @@ def beautify(self):
519519 self ._output .add_new_line ()
520520 else :
521521 self ._output .space_before_token = True
522+ elif (
523+ (self ._ch == ">" or self ._ch == "<" )
524+ and parenLevel > 0
525+ and self ._input .peek () == "="
526+ ):
527+ # Media query range operator: >= or <=
528+ # Ensure a single space before and after the operator
529+ self ._output .space_before_token = True
530+ self .print_string (self ._ch )
531+ self ._input .next () # consume '='
532+ self .print_string ("=" )
533+ self .eatWhitespace ()
534+ self ._output .space_before_token = True
535+ if bool (whitespaceChar .search (self ._ch )):
536+ self ._ch = ""
522537 elif (
523538 (self ._ch == ">" or self ._ch == "+" or self ._ch == "~" )
524539 and not insidePropertyValue
Original file line number Diff line number Diff line change @@ -388,6 +388,24 @@ exports.test_data = {
388388 input : '@media print {.tab{}}' ,
389389 output : '@media print{{curly_separator}}{\n .tab{{curly_separator2}}{}\n}'
390390 } ,
391+ {
392+ comment : 'Media query range operators should preserve spaces on both sides' ,
393+ unchanged : '@media (width >= 90rem) {\n .foo {}\n}'
394+ } ,
395+ {
396+ comment : 'Media query range operators should preserve spaces on both sides' ,
397+ unchanged : '@media (width <= 90rem) {\n .foo {}\n}'
398+ } ,
399+ {
400+ comment : 'Media query range operators - minified input should have spaces enforced around operator' ,
401+ input : '@media (width>=90rem){.foo{}}' ,
402+ output : '@media (width >= 90rem){{curly_separator}}{\n .foo{{curly_separator2}}{}\n}'
403+ } ,
404+ {
405+ comment : 'Media query range operators - minified input should have spaces enforced around operator' ,
406+ input : '@media (width<=90rem){.foo{}}' ,
407+ output : '@media (width <= 90rem){{curly_separator}}{\n .foo{{curly_separator2}}{}\n}'
408+ } ,
391409 {
392410 comment : 'This is bug #1489' ,
393411 input : '@media print {.tab,.bat{}}' ,
You can’t perform that action at this time.
0 commit comments