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

Toolkit creates invalid CSS when using double parentheses with calc() #308

Closed
1 task done
derweili opened this issue Jul 12, 2023 · 5 comments
Closed
1 task done

Comments

@derweili
Copy link
Member

Describe the bug

When using calc with double parentheses, toolkit produces invalid css output

Example input:

margin-left: calc((var(--inset-content-margin) * -1));

Example output

margin-left: (var(--inset-content-margin) * -1);

I know, having double parentheses is uncommon and unnecessary, but it's valid CSS according to W3C CSS Validator so I would expect toolkit to produce valid output.

This did not happen in toolkit version ^1.0.13.

Steps to Reproduce

  1. Apply following styles to an element:
--inset-content-margin: 1rem;
margin-left: (var(--inset-content-margin) * -1);
  1. Run build process. You will see the invalid CSS mentioned above.

Screenshots, screen recording, code snippet

Bildschirmfoto 2023-07-12 um 15 13 50

Environment information

  • Toolkit Version: 4.3.1

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Antonio-Laguna
Copy link
Member

@derweili could you provide more info regarding the steps to reproduce? It kind of goes in a different way to the first examples you pasted so I want to be sure I'm looking at the right thing.

@derweili
Copy link
Member Author

@Antonio-Laguna I just did some tests. So the issue only occurs with double parantheses combined with a custom property:

This works:

/** Input: **/
max-width: calc(100vw - 500px));

/** Output: **/
max-width: calc(100vw - 500px));

This does not work:

/** Input: **/
max-width: calc((var(--my-width) - 500px));

/** Output: **/
max-width: (var(--my-width) - 500px)

What other information do you need?

@Antonio-Laguna
Copy link
Member

I'm unsure how a calc would be removed in this instance. I'll dig deeper :)

@Antonio-Laguna
Copy link
Member

@derweili This is caused by CSSNANO and it's this issue specifically postcss/postcss-calc#77

I'd suggest my suggestion is not to add several parenthesis for the time being or disabling calc from CSSNANO but given you can still benefit from some of the calc benefits I'd say the former is preferred

@nicholasio
Copy link
Member

It sounds like this isn't something we can actually fix in toolkit so I'm closing this issue but if there's anything we need to do in toolkit regarding this issue feel free to reope.

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

3 participants