jsdom / cssstyle

A Node.js implementation of the CSS Object Model CSSStyleDeclaration interface
MIT License
107 stars 70 forks source link

HSL to RGB conversion results in black #142

Closed ianschmitz closed 8 months ago

ianschmitz commented 3 years ago

The logic for converting HSL to RGB appears to be flawed: https://github.com/jsdom/cssstyle/blob/b527ed722364dc6d156487c652df100572075dee/lib/utils/colorSpace.js#L13-L21

It refers to the W3 suggested logic for converting HSL to RGB, but their logic says that it expects the hue value to be normalized to a [0, 6) value which the logic in this package doesn't appear to do.

For example parsing:

hsl(85, 100%, 40%)

returns:

rgb(0, 0, 0)