parcel-bundler / parcel-bundler/lightningcss

lightningcss ate my precision

Open
#949 8 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
7.7k
Forks
302
PR merge metrics
No merged PRs in 30d

Description

I have a line-height which I have defined as

line-height: calc(4 / 3);

sass (annoyingly) turns this to

line-height: 1.3333333333;

Lightningcss compiles this to

line-height: 1.33333;

With a font-size of 12px, chrome's dev-tools reports this as a line-height of 16px.

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:

Image

How it does look:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported line-height case with calc(4 / 3) and compare Lightning CSS output with the layout result at a 12px font size. Read the discussion in #917 for related context. No source files or tests are named; done means defining and implementing a suitable float-precision option, with coverage for the reported precision-sensitive output.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, rust
Domain
compilers, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.