-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Polyfill: Fall back to first color value when color-mix(…)
contains unresolvable var(…)
#17513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polyfill: Fall back to first color value when color-mix(…)
contains unresolvable var(…)
#17513
Conversation
b3d75b2
to
64a3444
Compare
integrations/cli/index.test.ts
Outdated
@supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) { | ||
::placeholder { | ||
color: color-mix(in oklab, currentColor 50%, transparent); | ||
color: currentColor; | ||
@supports (color: color-mix(in lab, red, red)) { | ||
color: color-mix(in oklab, currentColor 50%, transparent); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit silly because we already have an @supports
query in preflight and now we chain another one but when you think about it, the first one only makes sure that Safari versions that crash are gated out. Older versions of Chrome/Firefox _that do not support color-mix(…)
would still not have a default in that case so this is a small improvement maybe?
In the future we might be able to clean this up if we use a different pass for applying that polyfill that has access to the parent path and then we can bail if this is already inside an @supprots
or so.
980326b
to
903ba82
Compare
… unresolvable `var(…)`
1a54575
to
30049fe
Compare
This PR further improves the
color-mix(…)
polyfill to create a reasonable fallback if dynamic values that can not statically be resolved are used. This refers to either the use ofcurrentcolor
or any variables that are not static theme variables.Here are two examples that now generate a reasonable fallback instead of not showing any color at all:
Test plan
<p className="text-shadow-lg/50 [--my-color:red] text-shadow-(color:--my-color)">shadow test</p>
color-mix(…)
will properly show a red shadow now albeit with 100% opacity: iOS 15.5 and Chrome 110var(…)var(…)
being chained with no space by lightningcss: Chrome 111