File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const CLOSE_BRACKET = ']'
1313const OPEN_BRACE = '{'
1414const CLOSE_BRACE = '}'
1515const EMPTY_BLOCK = '{}'
16+ const COMMA = ','
1617const TYPE_ATRULE = 'Atrule'
1718const TYPE_RULE = 'Rule'
1819const TYPE_BLOCK = 'Block'
@@ -150,7 +151,7 @@ export function format(css, { minify = false } = {}) {
150151 }
151152
152153 if ( item . next !== null ) {
153- buffer += `,` + NEWLINE
154+ buffer += COMMA + NEWLINE
154155 }
155156
156157 let end = item . next !== null ? start_offset ( item . next . data ) : end_offset ( node )
@@ -203,13 +204,13 @@ export function format(css, { minify = false } = {}) {
203204 break
204205 }
205206 case TYPE_SELECTORLIST : {
206- child . children . forEach ( ( grandchild , item ) => {
207- if ( grandchild . type === TYPE_SELECTOR ) {
208- buffer += print_simple_selector ( grandchild )
207+ child . children . forEach ( ( selector_list_item , item ) => {
208+ if ( selector_list_item . type === TYPE_SELECTOR ) {
209+ buffer += print_simple_selector ( selector_list_item )
209210 }
210211
211- if ( item . next ) {
212- buffer += ',' + SPACE
212+ if ( item . next && item . next . data . type === TYPE_SELECTOR ) {
213+ buffer += COMMA + OPTIONAL_SPACE
213214 }
214215 } )
215216 break
Original file line number Diff line number Diff line change @@ -83,4 +83,10 @@ test('removes whitespace before !important', () => {
8383 assert . equal ( actual , expected )
8484} )
8585
86+ test . only ( 'minifies complex selectors' , ( ) => {
87+ let actual = minify ( `:is(a, b) { color: green }` )
88+ let expected = `:is(a,b){color:green}`
89+ assert . equal ( actual , expected )
90+ } )
91+
8692test . run ( )
You can’t perform that action at this time.
0 commit comments