Skip to content

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

@sfentress

Description

@sfentress
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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions