Open Goodwine opened 3 months ago
In these cases, it is safer to use -webkit-linear-gradient instead of -webkit-gradient
Why?
WANT
You need to send PR for that. Since it is a feature for old browsers, I will not have time to implement it (too busy on preparing the slides for the talk).
Why? The CSS variable in the provided example contains a list of values rather than a single value. This variable is then in turn used as an argument for linear-gradient()`. Even though there is a "single" argument, browsers will expand that variable to be actually multiple arguments.
The issue in autoprefixer is that it thinks that the function has a single argument and proceeds to transform it under that assumption to -webkit-gradient(...)
. However, it can't introspect the CSS variable to determine whether it's a single value or a comma-separated list of values.
That limitation is reasonable, however I think Autoprefixer should be safer and either
Thankfully, we can use -webkit-linear-gradient()
instead of -webkit-gradient()
to achieve similar support but without generating "bad" CSS.
In other words, Autoprefixer assumes custom CSS properties contain 1 and only 1 value. But they could contain multiple values.
You need to send PR for that.
Sure, no rush, I can try sending a PR later. We can also always use autoprefixer: ignore next
. I just wanted to document this potential issue here :)
INPUT
GOT
WANT
In these cases, it is safer to use
-webkit-linear-gradient
instead of-webkit-gradient
: