Skip to content

Commit 0a4a064

Browse files
committed
swap the order of pseudo states
The current implementation had a strange side effect, that resulted in incorrect class definitions. When you are combining the `:hover` and `:focus` event, then there is no difference between `:hover:focus` and `:focus:hover`. However, when you use `:hover::file-selector-button` or `::file-selector-button:hover`, then there is a big difference. In the first place, you can hover over the full file input to apply changes to the `File selector button`. In the second scenario you have to hover over the `File selector button` itself to apply changes. You can think of it as function calls: - focus(hover(text-center)) What you would expect is something like this: `.focus\:hover\:text-center:hover:focus`, where `hover` is on the inside, and `focus` is on the outside. However in the current implementation this is implemented as `.focus\:hover\:text-cener:focus:hover`
1 parent 7e9e155 commit 0a4a064

8 files changed

+16
-16
lines changed

tests/important-modifier-prefix.test.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939
}
4040
@media (min-width: 1280px) {
41-
.xl\:focus\:disabled\:\!tw-float-right:focus:disabled {
41+
.xl\:focus\:disabled\:\!tw-float-right:disabled:focus {
4242
float: right !important;
4343
}
4444
}

tests/important-modifier.test.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939
}
4040
@media (min-width: 1280px) {
41-
.xl\:focus\:disabled\:\!float-right:focus:disabled {
41+
.xl\:focus\:disabled\:\!float-right:disabled:focus {
4242
float: right !important;
4343
}
4444
}

tests/kitchen-sink.test.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
.apply-test:hover {
2424
font-weight: 700;
2525
}
26-
.apply-test:focus:hover {
26+
.apply-test:hover:focus {
2727
font-weight: 700;
2828
}
2929
@media (min-width: 640px) {
3030
.apply-test {
3131
--tw-bg-opacity: 1;
3232
background-color: rgb(34 197 94 / var(--tw-bg-opacity));
3333
}
34-
.apply-test:focus:nth-child(even) {
34+
.apply-test:nth-child(even):focus {
3535
--tw-bg-opacity: 1;
3636
background-color: rgb(251 207 232 / var(--tw-bg-opacity));
3737
}
@@ -352,7 +352,7 @@ div {
352352
--tw-ring-opacity: 1;
353353
--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity));
354354
}
355-
.focus\:hover\:font-light:focus:hover {
355+
.focus\:hover\:font-light:hover:focus {
356356
font-weight: 300;
357357
}
358358
.disabled\:font-bold:disabled {

tests/layer-at-rules.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test('custom user-land utilities', () => {
4343
.hover\\:align-banana:hover {
4444
text-align: banana;
4545
}
46-
.focus\\:hover\\:align-chocolate:focus:hover {
46+
.focus\\:hover\\:align-chocolate:hover:focus {
4747
text-align: chocolate;
4848
}
4949
`)

tests/match-components.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ it('should be possible to matchComponents', () => {
7979
color: #f0f;
8080
}
8181
82-
.hover\\:card-\\[\\#f0f\\]:hover .hover\\:card-header:hover {
82+
.hover\\:card-\\[\\#f0f\\]:hover .card-header {
8383
border-top-width: 3px;
8484
border-top-color: #f0f;
8585
}
8686
87-
.hover\\:card-\\[\\#f0f\\]:hover .hover\\:card-footer:hover {
87+
.hover\\:card-\\[\\#f0f\\]:hover .card-footer {
8888
border-bottom-width: 3px;
8989
border-bottom-color: #f0f;
9090
}

tests/parallel-variants.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test('basic parallel variants', async () => {
4242
.test\\:font-medium *::test {
4343
font-weight: 500;
4444
}
45-
.hover\\:test\\:font-black:hover *::test {
45+
.hover\\:test\\:font-black *::test:hover {
4646
font-weight: 900;
4747
}
4848
.test\\:font-bold::test {
@@ -51,7 +51,7 @@ test('basic parallel variants', async () => {
5151
.test\\:font-medium::test {
5252
font-weight: 500;
5353
}
54-
.hover\\:test\\:font-black:hover::test {
54+
.hover\\:test\\:font-black::test:hover {
5555
font-weight: 900;
5656
}
5757
`)

tests/resolve-defaults-at-rules.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ test('with pseudo-class variants', async () => {
8484
--tw-rotate: 3deg;
8585
transform: var(--tw-transform);
8686
}
87-
.hover\\:focus\\:skew-y-6:hover:focus {
87+
.hover\\:focus\\:skew-y-6:focus:hover {
8888
--tw-skew-y: 6deg;
8989
transform: var(--tw-transform);
9090
}
@@ -252,12 +252,12 @@ test('with multi-class pseudo-element and pseudo-class variants', async () => {
252252
scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
253253
}
254254
/* --- */
255-
.group:hover .group-hover\\:hover\\:before\\:scale-x-110:hover::before {
255+
.group:hover .group-hover\\:hover\\:before\\:scale-x-110::before:hover {
256256
content: '';
257257
--tw-scale-x: 1.1;
258258
transform: var(--tw-transform);
259259
}
260-
.peer:focus ~ .peer-focus\\:focus\\:after\\:rotate-3:focus::after {
260+
.peer:focus ~ .peer-focus\\:focus\\:after\\:rotate-3::after:focus {
261261
content: '';
262262
--tw-rotate: 3deg;
263263
transform: var(--tw-transform);

tests/variants.test.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@
313313
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
314314
var(--tw-shadow);
315315
}
316-
.file\:hover\:bg-blue-600::file-selector-button:hover {
316+
.file\:hover\:bg-blue-600:hover::file-selector-button {
317317
--tw-bg-opacity: 1;
318318
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
319319
}
320-
.open\:hover\:bg-red-200[open]:hover {
320+
.open\:hover\:bg-red-200:hover[open] {
321321
--tw-bg-opacity: 1;
322322
background-color: rgb(254 202 202 / var(--tw-bg-opacity));
323323
}
@@ -326,7 +326,7 @@
326326
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
327327
var(--tw-shadow);
328328
}
329-
.focus\:hover\:shadow-md:focus:hover {
329+
.focus\:hover\:shadow-md:hover:focus {
330330
--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
331331
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
332332
var(--tw-shadow);

0 commit comments

Comments
 (0)