-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty CSS variables are incorrectly minified #7288
Comments
likely a bug in svelte itself, see css output tab in this repl https://svelte.dev/repl/06b3ee703d9542abb7a8bc35ff301f4b?version=3.46.4 |
It also looks like a Chrome only bug. Safari and Firefox renders fine. (Reminds me of this esbuild release) |
From my research in an earlier issue, this is technically a Chrome bug and will be fixed in the next release (99): #7152 (comment) |
Looks like the change to the spec that makes Personally I think it would be best to change this in Svelte regardless for better compatibility, it's a change lots of other tools have had to make as well since historically This is what the spec said last time I looked a couple of months ago:
...so I wouldn't be surprised if this sneaky problem shows up a lot for a while. It'll be a while before Electron is on 99 for example I bet. |
I'm going to close this in favor of #7152 regardless though, thanks for pointing me there! |
Fixes #7152, see also #7288 --foo:; used to be an invalid CSS custom property value, while -foo: ; was valid. By collapsing the whitespace in these declaration values, we were breaking scenarios where an empty custom property was desired. The spec was updated to trim whitespace and treat these values identically, but Chromium browsers still treat --foo; as invalid. This was recently fixed and will be released in Chrome 99, but this would still be a good fix to maintain backwards compatibility.
Fixes sveltejs#7152, see also sveltejs#7288 --foo:; used to be an invalid CSS custom property value, while -foo: ; was valid. By collapsing the whitespace in these declaration values, we were breaking scenarios where an empty custom property was desired. The spec was updated to trim whitespace and treat these values identically, but Chromium browsers still treat --foo; as invalid. This was recently fixed and will be released in Chrome 99, but this would still be a good fix to maintain backwards compatibility.
Describe the bug
This is valid CSS:
Importantly, the value of the variable is a single space character. SvelteKit is minifying this CSS (in development and production) to this:
This is syntactically invalid and breaks the semantics of the original CSS.
Unfortunately this breaks compatibility with Tailwind CSS, as we rely on empty variables to make certain types of styles composable, which you can read about in this blog post if would like a deeper explanation: https://adamwathan.me/composing-the-uncomposable-with-css-variables/
esbuild used to have the same bug but it was fixed a long time ago: evanw/esbuild#760
I've confirmed that esbuild is minifying this code safely:
...so I'm not sure where in the chain this is happening.
Reproduction
Here's a basic SvelteKit project that demonstrates the issue:
https://github.com/adamwathan/sveltekit-css-minification-bug/blob/main/src/routes/index.svelte
Logs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: