Add variable fallback to fix Chrome issue (#15003)

This works around an issue in Chrome where `::selection` does not read
from variables defined on `::selection` thus breaking all uses of color
utilities with the selection variant. e.g. `selection::bg-red-200`.

We now add a fallback value of `1` to all uses of
`var(--tw-bg-opacity)`, `var(--tw-text-opacity)`,
`var(--tw-border-opacity)`, etc… since Chrome treats the variable as if
it did not exist because it's not defined on the parent.

In Chrome 131 (until the change is rolled back) existing utilities like
these will not work:
- `selection:text-opacity-50`
- `selection:[--tw-text-opacity:0.5]`

Fixes #15000

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
This commit is contained in:
Jordan Pittman 2024-11-14 13:33:27 -05:00 • committed by GitHub
parent 4de07697bd
commit d093dce0fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 323 additions and 313 deletions

View file

@ -570,7 +570,7 @@
}
.divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
--tw-divide-opacity: 1;
border-color: rgb(229 231 235 / var(--tw-divide-opacity));
border-color: rgb(229 231 235 / var(--tw-divide-opacity, 1));
}
.divide-opacity-50 > :not([hidden]) ~ :not([hidden]) {
--tw-divide-opacity: 0.5;
@ -644,40 +644,40 @@
}
.border-black {
--tw-border-opacity: 1;
border-color: rgb(0 0 0 / var(--tw-border-opacity));
border-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
}
.border-x-black {
--tw-border-opacity: 1;
border-left-color: rgb(0 0 0 / var(--tw-border-opacity));
border-right-color: rgb(0 0 0 / var(--tw-border-opacity));
border-left-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
border-right-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
}
.border-y-black {
--tw-border-opacity: 1;
border-top-color: rgb(0 0 0 / var(--tw-border-opacity));
border-bottom-color: rgb(0 0 0 / var(--tw-border-opacity));
border-top-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
border-bottom-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
}
.border-b-black {
--tw-border-opacity: 1;
border-bottom-color: rgb(0 0 0 / var(--tw-border-opacity));
border-bottom-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
}
.border-l-black {
--tw-border-opacity: 1;
border-left-color: rgb(0 0 0 / var(--tw-border-opacity));
border-left-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
}
.border-r-black {
--tw-border-opacity: 1;
border-right-color: rgb(0 0 0 / var(--tw-border-opacity));
border-right-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
}
.border-t-black {
--tw-border-opacity: 1;
border-top-color: rgb(0 0 0 / var(--tw-border-opacity));
border-top-color: rgb(0 0 0 / var(--tw-border-opacity, 1));
}
.border-opacity-10 {
--tw-border-opacity: 0.1;
}
.bg-green-500 {
--tw-bg-opacity: 1;
background-color: rgb(34 197 94 / var(--tw-bg-opacity));
background-color: rgb(34 197 94 / var(--tw-bg-opacity, 1));
}
.bg-opacity-20 {
--tw-bg-opacity: 0.2;
@ -831,7 +831,7 @@
}
.text-indigo-500 {
--tw-text-opacity: 1;
color: rgb(99 102 241 / var(--tw-text-opacity));
color: rgb(99 102 241 / var(--tw-text-opacity, 1));
}
.text-opacity-10 {
--tw-text-opacity: 0.1;
@ -863,7 +863,7 @@
}
.placeholder-green-300::placeholder {
--tw-placeholder-opacity: 1;
color: rgb(134 239 172 / var(--tw-placeholder-opacity));
color: rgb(134 239 172 / var(--tw-placeholder-opacity, 1));
}
.placeholder-opacity-60::placeholder {
--tw-placeholder-opacity: 0.6;
@ -958,7 +958,7 @@
}
.ring-white {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(255 255 255 / var(--tw-ring-opacity));
--tw-ring-color: rgb(255 255 255 / var(--tw-ring-opacity, 1));
}
.ring-opacity-40 {
--tw-ring-opacity: 0.4;