Skip to content

Commit fa0e06c

Browse files
committed
Generate focus variants last and group-hover variants first
1 parent 02bac50 commit fa0e06c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

__tests__/variantsAtRule.test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ test('it can generate group-hover variants', () => {
6969
})
7070
})
7171

72-
test('it can generate hover and focus variants', () => {
72+
test('it can generate all variants', () => {
7373
const input = `
74-
@variants hover, focus {
74+
@variants hover, focus, group-hover {
7575
.banana { color: yellow; }
7676
.chocolate { color: brown; }
7777
}
@@ -80,10 +80,12 @@ test('it can generate hover and focus variants', () => {
8080
const output = `
8181
.banana { color: yellow; }
8282
.chocolate { color: brown; }
83-
.focus\\:banana:focus { color: yellow; }
84-
.focus\\:chocolate:focus { color: brown; }
83+
.group:hover .group-hover\\:banana { color: yellow; }
84+
.group:hover .group-hover\\:chocolate { color: brown; }
8585
.hover\\:banana:hover { color: yellow; }
8686
.hover\\:chocolate:hover { color: brown; }
87+
.focus\\:banana:focus { color: yellow; }
88+
.focus\\:chocolate:focus { color: brown; }
8789
`
8890

8991
return run(input).then(result => {
@@ -104,10 +106,10 @@ test('it wraps the output in a responsive at-rule if responsive is included as a
104106
@responsive {
105107
.banana { color: yellow; }
106108
.chocolate { color: brown; }
107-
.focus\\:banana:focus { color: yellow; }
108-
.focus\\:chocolate:focus { color: brown; }
109109
.hover\\:banana:hover { color: yellow; }
110110
.hover\\:chocolate:hover { color: brown; }
111+
.focus\\:banana:focus { color: yellow; }
112+
.focus\\:chocolate:focus { color: brown; }
111113
}
112114
`
113115

src/lib/substituteVariantsAtRules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function(config) {
4848

4949
atRule.before(atRule.clone().nodes)
5050

51-
_.forEach(['focus', 'hover', 'group-hover'], variant => {
51+
_.forEach(['group-hover', 'hover', 'focus'], variant => {
5252
if (variants.includes(variant)) {
5353
variantGenerators[variant](atRule, unwrappedConfig)
5454
}

0 commit comments

Comments
 (0)