11// copied from js-beautify/js/lib/beautify-css.js
2- // version: 1.14.7
2+ // version: 1.14.9
33/* AUTO-GENERATED. DO NOT MODIFY. */
44/*
55
@@ -1079,18 +1079,18 @@ function Beautifier(source_text, options) {
10791079
10801080 // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
10811081 this . NESTED_AT_RULE = {
1082- "@ page" : true ,
1083- "@ font-face" : true ,
1084- "@ keyframes" : true ,
1082+ "page" : true ,
1083+ "font-face" : true ,
1084+ "keyframes" : true ,
10851085 // also in CONDITIONAL_GROUP_RULE below
1086- "@ media" : true ,
1087- "@ supports" : true ,
1088- "@ document" : true
1086+ "media" : true ,
1087+ "supports" : true ,
1088+ "document" : true
10891089 } ;
10901090 this . CONDITIONAL_GROUP_RULE = {
1091- "@ media" : true ,
1092- "@ supports" : true ,
1093- "@ document" : true
1091+ "media" : true ,
1092+ "supports" : true ,
1093+ "document" : true
10941094 } ;
10951095 this . NON_SEMICOLON_NEWLINE_PROPERTY = [
10961096 "grid-template-areas" ,
@@ -1218,8 +1218,7 @@ Beautifier.prototype.beautify = function() {
12181218 // label { content: blue }
12191219 var insidePropertyValue = false ;
12201220 var enteringConditionalGroup = false ;
1221- var insideAtExtend = false ;
1222- var insideAtImport = false ;
1221+ var insideNonNestedAtRule = false ;
12231222 var insideScssMap = false ;
12241223 var topCharacter = this . _ch ;
12251224 var insideNonSemiColonValues = false ;
@@ -1274,10 +1273,32 @@ Beautifier.prototype.beautify = function() {
12741273
12751274 // Ensures any new lines following the comment are preserved
12761275 this . eatWhitespace ( true ) ;
1277- } else if ( this . _ch === '@' || this . _ch === ' $') {
1276+ } else if ( this . _ch === '$' ) {
12781277 this . preserveSingleSpace ( isAfterSpace ) ;
12791278
1280- // deal with less propery mixins @{...}
1279+ this . print_string ( this . _ch ) ;
1280+
1281+ // strip trailing space, if present, for hash property checks
1282+ var variable = this . _input . peekUntilAfter ( / [: , ; { } ( ) [ \] \/ = ' " ] / g) ;
1283+
1284+ if ( variable . match ( / [ : ] $ / ) ) {
1285+ // we have a variable or pseudo-class, add it and insert one space before continuing
1286+ variable = this . eatString ( ": " ) . replace ( / \s $ / , '' ) ;
1287+ this . print_string ( variable ) ;
1288+ this . _output . space_before_token = true ;
1289+ }
1290+
1291+ variable = variable . replace ( / \s $ / , '' ) ;
1292+
1293+ // might be sass variable
1294+ if ( parenLevel === 0 && variable . indexOf ( ':' ) !== - 1 ) {
1295+ insidePropertyValue = true ;
1296+ this . indent ( ) ;
1297+ }
1298+ } else if ( this . _ch === '@' ) {
1299+ this . preserveSingleSpace ( isAfterSpace ) ;
1300+
1301+ // deal with less property mixins @{...}
12811302 if ( this . _input . peek ( ) === '{' ) {
12821303 this . print_string ( this . _ch + this . eatString ( '}' ) ) ;
12831304 } else {
@@ -1295,22 +1316,21 @@ Beautifier.prototype.beautify = function() {
12951316
12961317 variableOrRule = variableOrRule . replace ( / \s $ / , '' ) ;
12971318
1298- if ( variableOrRule === 'extend' ) {
1299- insideAtExtend = true ;
1300- } else if ( variableOrRule === 'import' ) {
1301- insideAtImport = true ;
1302- }
1319+ // might be less variable
1320+ if ( parenLevel === 0 && variableOrRule . indexOf ( ':' ) !== - 1 ) {
1321+ insidePropertyValue = true ;
1322+ this . indent ( ) ;
13031323
1304- // might be a nesting at-rule
1305- if ( variableOrRule in this . NESTED_AT_RULE ) {
1324+ // might be a nesting at-rule
1325+ } else if ( variableOrRule in this . NESTED_AT_RULE ) {
13061326 this . _nestedLevel += 1 ;
13071327 if ( variableOrRule in this . CONDITIONAL_GROUP_RULE ) {
13081328 enteringConditionalGroup = true ;
13091329 }
1310- // might be less variable
1311- } else if ( ! insideRule && parenLevel === 0 && variableOrRule . indexOf ( ':' ) !== - 1 ) {
1312- insidePropertyValue = true ;
1313- this . indent ( ) ;
1330+
1331+ // might be a non-nested at-rule
1332+ } else if ( parenLevel === 0 && ! insidePropertyValue ) {
1333+ insideNonNestedAtRule = true ;
13141334 }
13151335 }
13161336 } else if ( this . _ch === '#' && this . _input . peek ( ) === '{' ) {
@@ -1322,6 +1342,9 @@ Beautifier.prototype.beautify = function() {
13221342 this . outdent ( ) ;
13231343 }
13241344
1345+ // non nested at rule becomes nested
1346+ insideNonNestedAtRule = false ;
1347+
13251348 // when entering conditional groups, only rulesets are allowed
13261349 if ( enteringConditionalGroup ) {
13271350 enteringConditionalGroup = false ;
@@ -1362,8 +1385,7 @@ Beautifier.prototype.beautify = function() {
13621385 if ( previous_ch === '{' ) {
13631386 this . _output . trim ( true ) ;
13641387 }
1365- insideAtImport = false ;
1366- insideAtExtend = false ;
1388+
13671389 if ( insidePropertyValue ) {
13681390 this . outdent ( ) ;
13691391 insidePropertyValue = false ;
@@ -1397,9 +1419,10 @@ Beautifier.prototype.beautify = function() {
13971419 }
13981420 }
13991421
1400- if ( ( insideRule || enteringConditionalGroup ) && ! ( this . _input . lookBack ( "&" ) || this . foundNestedPseudoClass ( ) ) && ! this . _input . lookBack ( "(" ) && ! insideAtExtend && parenLevel === 0 ) {
1422+ if ( ( insideRule || enteringConditionalGroup ) && ! ( this . _input . lookBack ( "&" ) || this . foundNestedPseudoClass ( ) ) && ! this . _input . lookBack ( "(" ) && ! insideNonNestedAtRule && parenLevel === 0 ) {
14011423 // 'property: value' delimiter
14021424 // which could be in a conditional group query
1425+
14031426 this . print_string ( ':' ) ;
14041427 if ( ! insidePropertyValue ) {
14051428 insidePropertyValue = true ;
@@ -1436,8 +1459,7 @@ Beautifier.prototype.beautify = function() {
14361459 this . outdent ( ) ;
14371460 insidePropertyValue = false ;
14381461 }
1439- insideAtExtend = false ;
1440- insideAtImport = false ;
1462+ insideNonNestedAtRule = false ;
14411463 this . print_string ( this . _ch ) ;
14421464 this . eatWhitespace ( true ) ;
14431465
@@ -1502,7 +1524,7 @@ Beautifier.prototype.beautify = function() {
15021524 } else if ( this . _ch === ',' ) {
15031525 this . print_string ( this . _ch ) ;
15041526 this . eatWhitespace ( true ) ;
1505- if ( this . _options . selector_separator_newline && ( ! insidePropertyValue || insideScssMap ) && parenLevel === 0 && ! insideAtImport && ! insideAtExtend ) {
1527+ if ( this . _options . selector_separator_newline && ( ! insidePropertyValue || insideScssMap ) && parenLevel === 0 && ! insideNonNestedAtRule ) {
15061528 this . _output . add_new_line ( ) ;
15071529 } else {
15081530 this . _output . space_before_token = true ;
0 commit comments