-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
[Bug]: discardEmpty removes empty custom property #1350
Comments
I confirm this bug. |
This bug also occurs for me. |
Thank you for the bug report.
I don't think we can check whether the property is being used, as the CSS using the property could be in a different stylesheet or even generated at runtime. I think we should preserve custom properties with a value set to empty string, as they're not equivalent to undefined properties. |
Fix #1350 Empty custom properties are valid according to the latest spec updates and various CSS tricks use them.
@ludofischer Yeah, you're right. Thank you for your fast answer and also your fix. ❤️ I'll close this issue as soon the release is done, ok? |
Fix #1350 Empty custom properties are valid according to the latest spec updates and various CSS tricks use them.
* fix(postcss-minify-params): reduce custom property value to 1 space instead of 0 Fix #1130 minify-params handles whitespace inside at rules separately from normalize-whitespace. I also realizes it uses a kind of hack, as it parses the atrule parameters with postcss-value-parser, so the resulting AST does not make a lot of sense. * fix(postcss-normalize-whitespace): turn empty custom properties into 1 space * fix(postcss-discard-empty): preserve empty custom properties Fix #1350 Empty custom properties are valid according to the latest spec updates and various CSS tricks use them. * test(postcss-discard-empty): test for property with space value
Describe the bug
In TailwindCSS, many custom properties are set, like
--tw-grayscale: ;
A class like.blur
sets following CSS:The problem is, if the class
.grayscale
is not used (who set a value, just like blur) the custom property get's removed and the classblur
doesn't work anymore.Expected behaviour
The custom properties should not be removed, when a class relies on the empty property
Steps to reproduce
I uploaded an example here: https://github.com/jonnitto/cssNanoDiscardEmpty: In the folder
disabled
the setting is disabled, in the folderenabled
, the setting is enabledI formatted
main.css
, so you can spot fast the difference.Version
5.1.1
Preset
default
Environment
Package details
Additional context
No response
The text was updated successfully, but these errors were encountered: