Skip to content

Commit 1efc5d1

Browse files
committed
Add support for :visited state variant
1 parent ca670f5 commit 1efc5d1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

__tests__/variantsAtRule.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,27 @@ test('it can generate active variants', () => {
5151
})
5252
})
5353

54+
test('it can generate visited variants', () => {
55+
const input = `
56+
@variants visited {
57+
.banana { color: yellow; }
58+
.chocolate { color: brown; }
59+
}
60+
`
61+
62+
const output = `
63+
.banana { color: yellow; }
64+
.chocolate { color: brown; }
65+
.visited\\:banana:visited { color: yellow; }
66+
.visited\\:chocolate:visited { color: brown; }
67+
`
68+
69+
return run(input).then(result => {
70+
expect(result.css).toMatchCss(output)
71+
expect(result.warnings().length).toBe(0)
72+
})
73+
})
74+
5475
test('it can generate focus variants', () => {
5576
const input = `
5677
@variants focus {

src/lib/substituteVariantsAtRules.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const defaultVariantGenerators = {
2626
'focus-within': generatePseudoClassVariant('focus-within'),
2727
focus: generatePseudoClassVariant('focus'),
2828
active: generatePseudoClassVariant('active'),
29+
visited: generatePseudoClassVariant('visited'),
2930
}
3031

3132
export default function(config, { variantGenerators: pluginVariantGenerators }) {

0 commit comments

Comments
 (0)