diff --git a/index.ts b/index.ts index eebde46..40564d6 100644 --- a/index.ts +++ b/index.ts @@ -193,10 +193,10 @@ export function format(css: string, { minify = false, tab_size = undefined }: Fo } case 'Combinator': { // putting spaces around `child.name` (+ > ~ or ' '), unless the combinator is ' ' - buffer += SPACE - - if (child.name !== ' ') { - buffer += child.name + SPACE + if (child.name === ' ') { + buffer += SPACE + } else { + buffer += OPTIONAL_SPACE + child.name + OPTIONAL_SPACE } break } diff --git a/package-lock.json b/package-lock.json index c235e0a..7b19903 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2550,9 +2550,9 @@ } }, "node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", "dev": true, "license": "ISC", "dependencies": { diff --git a/test/minify.test.ts b/test/minify.test.ts index f316cb6..295d3b3 100644 --- a/test/minify.test.ts +++ b/test/minify.test.ts @@ -85,3 +85,9 @@ test('minifies complex selectors', () => { let expected = `:is(a,b){color:green}` expect(actual).toEqual(expected) }) + +test('removes whitespace around non-whitespace selector combinators', () => { + let actual = minify(`a + b {} c d {}`) + let expected = `a+b{}c d{}` + expect(actual).toEqual(expected) +})