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

Colors can be stringified with expontential alphas, but cannot be parsed #156

Closed
sfentress opened this issue Apr 22, 2019 · 3 comments
Closed

Comments

@sfentress
Copy link

sfentress commented Apr 22, 2019

const c = new Color("hsl(0, 0%, 0%)").alpha(1.0e-7);
const c2 = new Color(c.string());
 > Uncaught Error: Unable to parse color from string: hsla(0, 0%, 0%, 1e-7)

Since the value entered in alpha in my application is computed, it is sometimes passed a number that is tiny. new Color is happy to accept it, and happy to turn it into a string, but cannot parse that string.

This can be solved on my end by using toFixed on the value before passed into alpha(), but it seems like this should be done on Color's side. I think there should be an expectation that any string Color produces should also be parsable.

@Qix-
Copy link
Owner

Qix- commented Apr 22, 2019

Agreed. Thanks for the report :)

@Qix-
Copy link
Owner

Qix- commented Dec 3, 2021

Fixed in color-string@1.9.0! I'll push an update out for color shortly.

@Qix- Qix- closed this as completed Dec 3, 2021
@Qix-
Copy link
Owner

Qix- commented Dec 3, 2021

Released as 4.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants