Skip to content
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

Fix broken minification for non-opaque oklab colors #901

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lfesp
Copy link

@lfesp lfesp commented Jan 25, 2025

Fixes incorrect addition of an extra hyphen to CSS output for floating-point values that are sufficiently low to be represented by scientific notation.

Context

If a value is represented by scientific notation, it may not be prefixed by "-0" but rather "-D", where D is some digit. In the code block below, if number < 0 but s is not prefixed by "-0", then two hyphens are written.

https://github.com/parcel-bundler/lightningcss/blob/0afd5d67196c1363e9f70aec8a763e786691255e/src/values/number.rs#L38C1-L49C13

This changes fixes this incorrect behavior by trimming additional leading hyphens ("-") from the string representation of the negative number.

Resolves Issue

This resolves issue with incorrect conversion from color-mix to oklab() (#899) resulting from double negative sign.
This issue is urgent for myself, as it causes Tailwind v4 classes using custom hex colors and non-100% opacity to break, as is seen in the reproduction here provided in the GH issue.

@lfesp lfesp changed the title Avoid invalid double hyphen for negative numbers in scientific notation Fix broken minification for non-opaque oklab colors Jan 25, 2025
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.

1 participant