diff --git a/src/compiler/compile/css/Stylesheet.ts b/src/compiler/compile/css/Stylesheet.ts index 8f88f0cbd406..0a3098db6d63 100644 --- a/src/compiler/compile/css/Stylesheet.ts +++ b/src/compiler/compile/css/Stylesheet.ts @@ -145,6 +145,10 @@ class Declaration { ? this.node.value.children[0] : this.node.value; + // Don't minify whitespace in custom properties, since some browsers (Chromium < 99) + // treat --foo: ; and --foo:; differently + if (first.type === 'Raw' && /^\s+$/.test(first.value)) return; + let start = first.start; while (/\s/.test(code.original[start])) start += 1; diff --git a/test/css/samples/css-vars/expected.css b/test/css/samples/css-vars/expected.css index c2bd56375b1f..d9ff79a2a9c8 100644 --- a/test/css/samples/css-vars/expected.css +++ b/test/css/samples/css-vars/expected.css @@ -1 +1 @@ -:root{--root-test:20}div.svelte-xyz{--test:10} \ No newline at end of file +:root{--root-test:20}div.svelte-xyz{--test:10}div.svelte-xyz{--foo: ;--bar: !important} \ No newline at end of file diff --git a/test/css/samples/css-vars/input.svelte b/test/css/samples/css-vars/input.svelte index 7aa48617a48b..4a969428ab6d 100644 --- a/test/css/samples/css-vars/input.svelte +++ b/test/css/samples/css-vars/input.svelte @@ -7,4 +7,9 @@ div { --test: 10; } + + div { + --foo: ; + --bar: !important; + }