mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Only wrap with variants if rules don't already contain any variants
This commit is contained in:
parent
3f6d31e3ae
commit
7dc0261bc6
@ -1261,6 +1261,33 @@ test('plugins can use the array shorthand to add variants to components', () =>
|
||||
`)
|
||||
})
|
||||
|
||||
test('components that add variants manually do not add an extra variants wrapper', () => {
|
||||
const { components } = processPlugins(
|
||||
[
|
||||
function({ addComponents }) {
|
||||
addComponents({
|
||||
'@variants responsive': {
|
||||
'.btn-blue': {
|
||||
backgroundColor: 'blue',
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
],
|
||||
makeConfig()
|
||||
)
|
||||
|
||||
expect(css(components)).toMatchCss(`
|
||||
@layer components {
|
||||
@variants responsive {
|
||||
.btn-blue {
|
||||
background-color: blue
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
test("component declarations are not affected by the 'important' option", () => {
|
||||
const { components } = processPlugins(
|
||||
[
|
||||
|
||||
@ -2,6 +2,16 @@ import postcss from 'postcss'
|
||||
import cloneNodes from './cloneNodes'
|
||||
|
||||
export default function wrapWithVariants(rules, variants) {
|
||||
let foundVariantAtRule = false
|
||||
|
||||
postcss.root({ nodes: rules }).walkAtRules('variants', () => {
|
||||
foundVariantAtRule = true
|
||||
})
|
||||
|
||||
if (foundVariantAtRule) {
|
||||
return cloneNodes(rules)
|
||||
}
|
||||
|
||||
return postcss
|
||||
.atRule({
|
||||
name: 'variants',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user