Skip to content

Commit 1250113

Browse files
committed
Always return alpha from normalize
1 parent e70d288 commit 1250113

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/components/color/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const opacity = (cstr) => (cstr ? color(cstr).alpha() : 0);
4949
* @return {Number[]|Uint8Array}
5050
*/
5151
const normalize = (cstr, type) => {
52-
const [r, g, b, a] = color(cstr).rgb().array();
52+
// color's `.rgb().array()` omits alpha when it is 1, so default `a`
53+
// back to 1 to keep the 4-element shape callers expect.
54+
const [r, g, b, a = 1] = color(cstr).rgb().array();
5355
if (type === 'uint8') {
5456
const out = new Uint8Array(4);
5557
out[0] = r;

0 commit comments

Comments
 (0)