bgrins / TinyColor

Fast, small color manipulation and conversion for JavaScript
https://bgrins.github.io/TinyColor/
MIT License
5.05k stars 439 forks source link

RGBA fails to parse if alpha is missing #274

Open ebshimizu opened 7 months ago

ebshimizu commented 7 months ago

According to the CSS spec the alpha parameter in the rgba color string is optional:

<modern-rgba-syntax> = rgba( [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? )

Tinycolor fails to parse cases where rgba() colors string have no alpha because it expects exactly four values when it should be expecting three and an optional fourth: https://github.com/bgrins/TinyColor/blob/b49018c9f2dbca313d80d7a4dad25e26143cfe01/tinycolor.js#L1039