Skip to content

Fix broken minification for non-opaque oklab colors #901

Merged
devongovett merged 1 commit intoparcel-bundler:masterfrom
lfesp:master
Mar 5, 2025
Merged

Fix broken minification for non-opaque oklab colors #901
devongovett merged 1 commit intoparcel-bundler:masterfrom
lfesp:master

Conversation

@lfesp
Copy link
Copy Markdown
Contributor

@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
@titanve
Copy link
Copy Markdown

titanve commented Mar 4, 2025

Great! Hope to see this commit merged and released soon 💪 !

@devongovett devongovett merged commit b153413 into parcel-bundler:master Mar 5, 2025
joshuadavidthomas pushed a commit to joshuadavidthomas/lightningcss that referenced this pull request Mar 10, 2025
joshuadavidthomas pushed a commit to joshuadavidthomas/lightningcss that referenced this pull request Mar 10, 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.

3 participants