color-js/color.js

Scientific notation causes error in OKLCH?

Closed this issue · 2 comments

Discussed in #507

Originally posted by maybebansky April 26, 2024
I'm using scientific notation for color channels that I pass to the Color object in the OKLCH format.

I know it's a bit weird but I'm getting these values as a result of color manipulation elsewhere in my app.

// This works fine
const color1 = new Color("oklch(50% 4 30)");

// This errors
const color2 = new Color("oklch(50% 4.0e-1 30)");

"oklch(50% 4.0e-1 30)" does appear to be valid CSS so is this technically a bug (albeit it an edge case)?

The error is

Uncaught TypeError: undefined not allowed for Chroma in oklch()

So, fixed due to #508 ?

Yes. This is now fixed.