-
Notifications
You must be signed in to change notification settings - Fork 200
lightningcss ate my precision #949
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
Comments
On further inspection, it seems like sass ate the fractions, but did at least emit with sufficient precision. However, forcing sass to emit the raw calc is a mite annoying, and the underlying problem is that lightningcss over-zealously rounds. |
The current behavior matches how browsers serialize CSS numbers. See https://codepen.io/devongovett/pen/pvvyqKb This is defined in the specification: https://drafts.csswg.org/cssom/#serializing-css-values
|
Thanks for the response. Chrome appears to be doing something strange with its rounding (or not rounding) then: https://codepen.io/billhp/pen/YPPWWYN in chrome: in firefox: Would it be possible to ask lightningcss to emit warnings when it truncates fractions - e.g. something on the lines of
In my case the problem was sass eating the fractions (and emitting non-spec-compliant but working decimals), and also the difference in behaviour between browsers (I still can't tell which one is doing it Right ™️). Having lightningcss provide a safety net here would be very helpful. |
I have a line-height which I have defined as
sass (annoyingly) turns this to
Lightningcss compiles this to
With a font-size of
12px
, chrome's dev-tools reports this as a line-height of16px
.However, the computed layout reports an element height of
15.984px
. This results in a 1px upshift of content meaning it appears uncentered.Adding another two digits of precision fixes the issue, but ideally I would like some option to be able to specify the precision of floats.
See also #917
How it should look:
How it does look:
The text was updated successfully, but these errors were encountered: