Skip to content

fix(color): prevent NaN saturation in HSLA to HSBA at zero lightness#8845

Closed
Chessing234 wants to merge 1 commit into
processing:mainfrom
Chessing234:fix/hsla-to-hsba-zero-lightness
Closed

fix(color): prevent NaN saturation in HSLA to HSBA at zero lightness#8845
Chessing234 wants to merge 1 commit into
processing:mainfrom
Chessing234:fix/hsla-to-hsba-zero-lightness

Conversation

@Chessing234
Copy link
Copy Markdown

Bug

color.toString('hsb') returns NaN saturation for HSL black (color(0, 100, 0) in HSL mode).

Root cause

_hslaToHSBA divides by val when computing saturation. For zero lightness, val is 0, producing 0/0.

Why this fix is correct

Return saturation 0 when val === 0, matching how _hsbaToHSLA already guards the li === 1 case.

Resolves N/A (discovered during color conversion review; no open issue).

PR Checklist

  • npm run lint passes
  • [Inline reference] is included / updated
  • [Unit tests] are included / updated

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@Chessing234 Chessing234 closed this by deleting the head repository May 29, 2026
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