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

Compiling clamp with mixed units vw and rem fails #648

Open
rintisch opened this issue Jul 7, 2023 · 2 comments
Open

Compiling clamp with mixed units vw and rem fails #648

rintisch opened this issue Jul 7, 2023 · 2 comments
Labels
enhancement New feature or request spec compliance Issues with compliance to the Sass spec
Milestone

Comments

@rintisch
Copy link

rintisch commented Jul 7, 2023

When compiling e.g. clamp(0.2rem, 0.2rem + 0.12vw, 0.3rem) the Compiler fails in the method compileString() line 573 with the message Incompatible units vw and rem.: line: <line-number>, column: <column-number>.

It works when using clamp(0.2rem, calc(0.2rem + 0.12vw), 0.3rem) but calc() is optional ,see https://web.dev/min-max-clamp/

When using a calculation inside of a min(), max(), or clamp() function, you can remove the call to calc(). For example, writing font-size: max(calc(0.5vw - 1em), 2rem) would be the same as font-size: max(0.5vw - 1em, 2rem).

@stof
Copy link
Member

stof commented Jul 7, 2023

We haven't implemented support for first-class calc yet in scssphp (doing that in our 1.x codebase is too hard, so this is scheduled to be part of the upcoming 2.0 release, once I have time again to move it forward). Because of that, 0.2rem + 0.12vw is interpreted as a Sass addition. Wrapping it in calc() works because calc() has a special parsing.

When looking at the compatibility notes in the documentation about calculations, the support in scssphp 1.x is equivalent to the support in libsass.

@rintisch
Copy link
Author

rintisch commented Jul 7, 2023

@stof Thank you for the fast feedback and explanations!

@stof stof added enhancement New feature or request spec compliance Issues with compliance to the Sass spec labels Jul 7, 2023
@stof stof added this to the 2.0 milestone Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request spec compliance Issues with compliance to the Sass spec
Projects
None yet
Development

No branches or pull requests

2 participants