From f8f5c80a03b0969e5de8210ff71876c5ac94bb30 Mon Sep 17 00:00:00 2001 From: Bart Veneman Date: Fri, 15 Mar 2024 23:49:59 +0100 Subject: [PATCH] fix spacing after colon inside atrule prelude `selector()` --- index.js | 2 +- test/atrules.test.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c0e1b69..4ed147a 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/test/atrules.test.js b/test/atrules.test.js index 23d9709..633581d 100644 --- a/test/atrules.test.js +++ b/test/atrules.test.js @@ -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) {