Skip to content

Colour precision too high #1252

@eniallator

Description

@eniallator

I've just added lightningcss (version 1.32.0) to my project and I've got some oklch colour values which get converted to lab/rgb.
I've just been scanning through the output and it seems like only some of the output lab colours have far too much precision on them.

I've come up with a minimal reproduction:

import { browserslistToTargets, transform } from "lightningcss";

console.log(
  transform({
    code: Buffer.from(`.element { color: oklch(0.708 0 0); }`),
    targets: browserslistToTargets(["chrome 100"]),
  }).code.toString(),
);

which outputs:

.element {
  color: #a1a1a1;
  color: lab(66.128% -.0000298023 .0000119209);
}

It seems like the 2 trailing channels should just be rounded to 0?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions