File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ export function format(css, { minify = false } = {}) {
163163 return buffer
164164 }
165165
166- /** @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector } node */
166+ /** @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector|import('css-tree').PseudoElementSelector } node */
167167 function print_simple_selector ( node ) {
168168 let buffer = EMPTY_STRING
169169 let children = node . children || [ ]
@@ -183,19 +183,15 @@ export function format(css, { minify = false } = {}) {
183183 }
184184 break
185185 }
186+ case 'PseudoClassSelector' :
186187 case 'PseudoElementSelector' : {
187- buffer += COLON + COLON
188- buffer += lowercase ( child . name )
189- break
190- }
191- case 'PseudoClassSelector' : {
192188 buffer += COLON
193189
194190 // Special case for `:before` and `:after` which were used in CSS2 and are usually minified
195191 // as `:before` and `:after`, but we want to print them as `::before` and `::after`
196192 let pseudo = lowercase ( child . name )
197193
198- if ( pseudo === 'before' || pseudo === 'after' ) {
194+ if ( pseudo === 'before' || pseudo === 'after' || child . type === 'PseudoElementSelector' ) {
199195 buffer += COLON
200196 }
201197
Original file line number Diff line number Diff line change @@ -180,6 +180,14 @@ li:nth-child() {}`
180180 assert . equal ( actual , expected )
181181} )
182182
183+ test ( `formats ::highlight and ::highlight(Name) correctly` , ( ) => {
184+ let actual = format ( `::highlight,::highlight(Name),::highlight(my-thing) {}` )
185+ let expected = `::highlight,
186+ ::highlight(Name),
187+ ::highlight(my-thing) {}`
188+ assert . equal ( actual , expected )
189+ } )
190+
183191test ( 'formats unknown pseudos correctly' , ( ) => {
184192 let actual = format ( `
185193 ::foo-bar,
You can’t perform that action at this time.
0 commit comments