Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function print_prelude(node, css) {
let buffer = substr(node, css)

return buffer
.replace(/\s*([:,])/g, '$1 ') // force whitespace after colon or comma
.replace(/\s*([:,])/g, buffer.includes('selector(') ? '$1' : '$1 ') // force whitespace after colon or comma, except inside `selector()`
.replace(/\s*(=>|<=)\s*/g, ' $1 ') // force whitespace around => and <=
.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')
.replace(/\s+/g, SPACE) // collapse multiple whitespaces into one
Expand Down
3 changes: 2 additions & 1 deletion test/atrules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ test('AtRule prelude formatting', () => {
[`@supports (display:grid){}`, `@supports (display: grid) {}`],
[`@supports (-webkit-appearance: none) {}`, `@supports (-webkit-appearance: none) {}`],
[`@media all and (-moz-images-in-menus:0) and (min-resolution:.001dpcm) {}`, `@media all and (-moz-images-in-menus: 0) and (min-resolution: .001dpcm) {}`],
[`@media all and (-webkit-min-device-pixel-ratio: 10000),not all and (-webkit-min-device-pixel-ratio: 0) {}`, `@media all and (-webkit-min-device-pixel-ratio: 10000), not all and (-webkit-min-device-pixel-ratio: 0) {}`]
[`@media all and (-webkit-min-device-pixel-ratio: 10000),not all and (-webkit-min-device-pixel-ratio: 0) {}`, `@media all and (-webkit-min-device-pixel-ratio: 10000), not all and (-webkit-min-device-pixel-ratio: 0) {}`],
['@supports selector([popover]:open) {}', '@supports selector([popover]:open) {}'],
]

for (let [css, expected] of fixtures) {
Expand Down