jsdom / cssstyle

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

Hex values without # are missed #54

Closed Impally closed 5 years ago

Impally commented 6 years ago

The CSS Style declaration looks for only a # followed by 6 characters for Hex values, browsers treat the # as optional and will resolve any value 0-ffffff as hex. The change seems pretty simple, change the regex in parse.js .

fatfisz commented 5 years ago

A quick check in Chrome shows that this is not the case, at least not for all browsers:

> element.style.backgroundColor = 'fff'
"fff"

> element.style.backgroundColor
"initial"

> element.style.backgroundColor = '#fff'
"#fff"

> element.style.backgroundColor
"rgb(255, 255, 255)"

Could you provide an example of a browser that works without #?

fatfisz commented 5 years ago

Closing because of no activity.