styled-components/polished

`rgbToColorString` produces wrong color when `alpha` is `0`

sgoll opened this issue · 1 comments

sgoll commented
  • polished version: 3.6.3

Mixin/Helper/Shorthand Usage

rgbToColorString({ red: 255, green: 205, blue: 100, alpha: 0.0 })

What You Are Seeing

The (wrong) result is #ffcd64.

What You Expected To See

The expected result is rgba(255,205,100,0).

Reproduction

https://codesandbox.io/s/patient-lake-tdqty

Analysis

The problem is this comparison:

if (color.alpha && typeof color.alpha === 'number') {

The evaluation of color.alpha is probably not necessary at all. Any not-null (null/undefined) checks are included in typeof color.alpha === 'number' already.

Thank you for filing the issue @sgoll. v3.6.4 addresses this issue.