From 168d3424a8f1186d82c709a7a74adda5a9c8d12b Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Sat, 22 Jun 2024 13:25:47 -0400 Subject: [PATCH] bug/issue 1242 handle optimization ordering issue with functions in CSS declarations (#1243) * handle optimization ordering issue with functions in CSS declarations * remove extra comment --- packages/cli/src/plugins/resource/plugin-standard-css.js | 2 +- .../build.config.optimization-default/fixtures/expected.css | 4 +++- .../build.config.optimization-default/src/styles/main.css | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/plugins/resource/plugin-standard-css.js b/packages/cli/src/plugins/resource/plugin-standard-css.js index 64c1ba00d..b98e3bfb4 100644 --- a/packages/cli/src/plugins/resource/plugin-standard-css.js +++ b/packages/cli/src/plugins/resource/plugin-standard-css.js @@ -96,7 +96,7 @@ function bundleCss(body, url, compilation) { } } else if (type === 'Function') { /* ex: border-left: 3px solid var(--color-secondary); */ - if (this.declaration && item.prev && item.prev.data.type === 'Identifier') { + if (this.declaration && item.prev && (item.prev.data.type !== 'Operator' && item.prev.data.type !== 'Url')) { optimizedCss += ' '; } optimizedCss += `${name}(`; diff --git a/packages/cli/test/cases/build.config.optimization-default/fixtures/expected.css b/packages/cli/test/cases/build.config.optimization-default/fixtures/expected.css index 2820fe9d5..51eaddcf3 100644 --- a/packages/cli/test/cases/build.config.optimization-default/fixtures/expected.css +++ b/packages/cli/test/cases/build.config.optimization-default/fixtures/expected.css @@ -58,4 +58,6 @@ a[href*='greenwood'],a[href$='.pdf']{color:orange} h1:has(+h2){margin:0 0 0.25rem 0} -:is(ol,ul,menu:unsupported) :is(ol,ul){color:green} \ No newline at end of file +:is(ol,ul,menu:unsupported) :is(ol,ul){color:green} + +.snippet{margin:var(--size-4) 0;padding:0 var(--size-4);} \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.optimization-default/src/styles/main.css b/packages/cli/test/cases/build.config.optimization-default/src/styles/main.css index 947b402f6..8877b8e21 100644 --- a/packages/cli/test/cases/build.config.optimization-default/src/styles/main.css +++ b/packages/cli/test/cases/build.config.optimization-default/src/styles/main.css @@ -130,4 +130,9 @@ h1:has(+ h2) { :is(ol, ul, menu:unsupported) :is(ol, ul) { color: green; +} + +.snippet { + margin: var(--size-4) 0; + padding: 0 var(--size-4); } \ No newline at end of file