Skip to content
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

Custom properties are not replaced with their values when preserve: false #661

Closed
2 of 3 tasks
ZauberNerd opened this issue Oct 20, 2022 · 5 comments
Closed
2 of 3 tasks

Comments

@ZauberNerd
Copy link

ZauberNerd commented Oct 20, 2022

Bug description

Since postcss-custom-properties 12.1.9 custom properties are not correctly replaced in some cases, while still removing their declaration when setting preserve: false.

This leads to generated CSS that contains a reference to a custom property, but not the custom property itself, thus causing it not to be applied.

This bug seems to be introduced by: #620, which was caused by: #619

Source CSS

:root {
  --some-value: red;
}

body {
  color: red; /* fallback for browsers that do not support custom properties */
  color: var(--some-value);
}

Expected CSS

body {
  color: red;
}

/* or maybe even repeating the color declaration, like postcss-custom-properties@12.1.8 did */
body {
  color: red;
  color: red;
}

Actual CSS

body {
  color: red; /* fallback for browsers that do not support custom properties */
  color: var(--some-value);
}

Does it happen with npx @csstools/csstools-cli <plugin-name> minimal-example.css?

Yes

Debug output

No response

Extra config

npx @csstools/csstools-cli postcss-custom-properties minimal-example.css -p '{"preserve":false}'

What plugin are you experiencing this issue on?

PostCSS Custom Properties

Plugin version

12.1.9

What OS are you experiencing this on?

Linux

Node Version

18.11.0

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@romainmenke
Copy link
Member

Hi @ZauberNerd thank you for reaching out!

We indeed overlooked this pattern in 12.1.9.
A fix has been prepared and we will try to make available shortly : #662

romainmenke added a commit that referenced this issue Oct 20, 2022
…ode (#662)

* custom-properties : add failing test for #661

* fix

* closing tags

* clarify changelog
@romainmenke
Copy link
Member

@ZauberNerd
Copy link
Author

Wow, this was really fast. I'm on my way into the weekend, so I'll check on Monday morning

@ZauberNerd
Copy link
Author

@romainmenke thanks for fixing this. It works again!

@romainmenke
Copy link
Member

@ZauberNerd Thank you for verifying 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants