Skip to content

CSS output for LCH color spaces uses NaN, producing invalid color #357

@haykam821

Description

@haykam821

Hey! With chroma.js 3.0.0, the css method seems to produce invalid values for certain colors:

chroma('white').lch(); // [100,0,NaN]
chroma('white').css("lch"); // "lch(100% 0 NaNdeg)"

Tested in a browser, lch(100% 0 NaNdeg) is an invalid color value. I would expect the css method to always provide a valid color value, even if the color doesn't necessarily make sense in the given color space.

I believe this issue is not a duplicate of #322, as the css method previously took care when handling NaN, regardless of whether hsl included NaN in its output:

chroma('white').hsl(); // [NaN,0,1,1]
chroma('white').css("hsl"); // "hsl(0deg 0% 100%)"

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions