Skip to content

Commit

Permalink
Merge branch 'browner12-empty-variant'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed May 7, 2021
2 parents 86e9c34 + ba1902b commit b6286c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/substituteVariantsAtRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const defaultVariantGenerators = (config) => ({
last: generatePseudoClassVariant('last-child', 'last'),
odd: generatePseudoClassVariant('nth-child(odd)', 'odd'),
even: generatePseudoClassVariant('nth-child(even)', 'even'),
empty: generatePseudoClassVariant('empty'),
})

function prependStackableVariants(atRule, variants, stackableVariants) {
Expand Down
1 change: 1 addition & 0 deletions stubs/defaultConfig.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ module.exports = {
'even',
'visited',
'checked',
'empty',
'group-hover',
'group-focus',
'focus-within',
Expand Down
21 changes: 21 additions & 0 deletions tests/variantsAtRule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,27 @@ test('it can generate even variants', () => {
})
})

test('it can generate empty variants', () => {
const input = `
@variants empty {
.banana { color: yellow; }
.chocolate { color: brown; }
}
`

const output = `
.banana { color: yellow; }
.chocolate { color: brown; }
.empty\\:banana:empty { color: yellow; }
.empty\\:chocolate:empty { color: brown; }
`

return run(input).then((result) => {
expect(result.css).toMatchCss(output)
expect(result.warnings().length).toBe(0)
})
})

test('it can generate group-hover variants', () => {
const input = `
@variants group-hover {
Expand Down

0 comments on commit b6286c9

Please sign in to comment.