jsdom / cssstyle

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

Color function values are not properly rounded #134

Open cdoublev opened 3 years ago

cdoublev commented 3 years ago

This test expectation is wrong:

style.color = 'rgba(5%, 10%, 20%, 0.4)';
expect(style.color).toEqual('rgba(12, 25, 51, 0.4)');

In Chrome/Firefox:

target.style.backgroundColor = 'rgba(5%, 10%, 20%, 0.4)'
console.log(target.style.backgroundColor) // "rgba(13, 26, 51, 0.4)"

Spec:

Implementations should honor the precision of the channel as authored or calculated wherever possible. If this is not possible, the channel should be rounded towards +∞.