jsdom / cssstyle

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

Colors are not interpreted correctly #48

Closed SidneyNemzer closed 5 years ago

SidneyNemzer commented 7 years ago

Keywords CSS has hundreds of color keywords, but CSSStyle only recognizes a few https://github.com/chad3814/CSSStyleDeclaration/blob/master/lib/parsers.js#L100-L116

HSL and HSLA CSSStyle has no logic to interpret HSL or HSLA values. Here's the regex for Hex, RGA, and RGBA. HSL and HSLA are missing.

https://github.com/chad3814/CSSStyleDeclaration/blob/master/lib/parsers.js#L28-L30

Computing the result Hex values are correctly converted to RGB, however keywords (even valid ones) are not. If CSSStyle intends to emulate a browser's behavior, it should convert everything to RGB or RGBA

TLDR CSSStyle doesn't handle color values correctly

FagnerMartinsBrack commented 7 years ago

This is causing an issue with JSDOM.

PavelPZ commented 6 years ago

... and all its dependencies, as JEST, REACT-TESTING-LIBRARY etc. Is PR welcomed? Can I fix parsers.js?

bennypowers commented 5 years ago

This breaks lighthouse tests:

screenshot 2019-02-02 22 01 08 screenshot 2019-02-02 22 00 57