File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -1276,19 +1276,21 @@ class AtRule extends CSSParserRule {
12761276 }
12771277 toSource ( indent = 0 ) {
12781278 let s = printIndent ( indent ) + "@" + escapeIdent ( this . name ) ;
1279- s += this . prelude . map ( x => x . toSource ( ) ) . join ( "" ) ;
1280- if ( this . declarations == null ) {
1281- s += ";\n" ;
1279+ let prelude = this . prelude . map ( x => x . toSource ( ) ) . join ( "" ) ;
1280+ while ( prelude . endsWith ( ' ' ) ) { prelude = prelude . slice ( 0 , - 1 ) ; }
1281+ if ( this . declarations === null ) {
1282+ s += prelude + ";" ;
12821283 return s ;
12831284 }
1284- s += "{\n" ;
1285- if ( this . declarations . length ) {
1286- s += this . declarations . map ( x => x . toSource ( indent + 1 ) ) . join ( "\n" ) + "\n" ;
1287- }
1288- if ( this . rules . length ) {
1289- s += this . rules . map ( x => x . toSource ( indent + 1 ) ) . join ( "\n" ) + "\n" ;
1285+ s += prelude + " " ;
1286+ if ( this . declarations . length || this . rules . length ) {
1287+ s += "{\n" +
1288+ this . declarations . map ( x => x . toSource ( indent + 1 ) + "\n" ) . join ( "" ) +
1289+ this . rules . map ( x => x . toSource ( indent + 1 ) + "\n" ) . join ( "" ) +
1290+ printIndent ( indent ) + "}" ;
1291+ } else {
1292+ s += "{ }" ;
12901293 }
1291- s += printIndent ( indent ) + "}" ;
12921294 return s ;
12931295 }
12941296}
You can’t perform that action at this time.
0 commit comments