-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add specs for unit math with multiple units #1205
Conversation
@nex3 the difference in ruby and dart output is significant, which output is correct for libsass? |
I think |
@nex3 can you elaborate why the following: .test {
test1: inspect((23px/2fu/12emu/1.2gnu));
} Results in: .test {
test1: 0.7986111111px/emu*fu*gnu;
} Or will this change with sass/sass#2457 ? I have no problem coming up with a mathematically correct version, but I have a hard time to preserve the same unit in the output as ruby sass and throwing errors for incompatible operations at the same time. |
BTW. since you seem to have introduced exponent notation ( Another small issue I had with my implementation was that it initially converted the following: .test {
$nr: (1s*1000ms);
test: inspect($nr);
} To: .test {
test: 1s^2; } Whereas ruby sass gives: .test {
test: 1000ms*s; } Note: in order to preserve the same unit as ruby sass does, we need to postpone the number normalization in LibSass from after each operation step to when it is actually used. This will degrade performance a bit, since it means that we need i.e. to copy and normalize numbers each time we do a compare operation on numbers or other things that need the numbers normalized. Will make some profiling once it passes all tests again. |
@nex3 here some other small things I discovered regarding units and numbers I would consider "wrong": .test {
fails: percentage(0.1%);
works: nth(1 2 3, 2px);
true: hue(hsla(120%, 20, 42%, 1)) == 120deg;
} I would have expected to allow percentages anywhere unitless numbers are wanted (as in
|
Every time you divide by a (non-convertable) unit, that unit is added to the denominator units of the number.
No. Dart Sass just uses that notation because I thought it was clearer than
I'd say both of these are correct. If normalizing eagerly here is easier for you, go for it.
The percentage behavior here is unfortunately inherited from CSS. I agree that it would make sense to treat We don't enforce unitless numbers in various built-in functions purely for backwards-compatibility reasons. Ideally they wouldn't be allowed, but it's not a big enough wart to be worth a deprecation process. |
Skip dart-sass
Skip ruby-sass