Skip to content

Add tests for calculation constants#1890

Merged
nex3 merged 2 commits intomainfrom
calc-constants
Mar 23, 2023
Merged

Add tests for calculation constants#1890
nex3 merged 2 commits intomainfrom
calc-constants

Conversation

@nex3
Copy link
Contributor

@nex3 nex3 commented Mar 23, 2023

Closes #1885
See sass/sass#3258

[skip dart-sass]

<===>
================================================================================
<===> pi/math/simplified/input.scss
a {b: calc(pi * 2)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we had a tau constant 🤣

a {b: math.div(0px * 0em, 0)}

<===> error/nan/multiple_numerator_units/error
Error: calc(NaNpx*em) isn't a valid CSS value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think that for NaN and infinity, having the units adjacent to the value makes the error difficult to read for me. I wonder if it would be possible to have a space in between them only for the cases of NaN and infitnity. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better solution here would be to have a more principled behavior for representing multi-unit values in general using calc, but that's outside the scope of the current change.

@nex3 nex3 merged commit d7e7eaf into main Mar 23, 2023
@nex3 nex3 deleted the calc-constants branch March 23, 2023 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for calc constants

2 participants