Allow the use of @media print without parens (#5898)
This commit is contained in:
parent
5058275f3b
commit
fd9dbe18ac
2 changed files with 28 additions and 3 deletions
|
|
@ -230,7 +230,7 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
|
|||
return ({ format }) => format(str)
|
||||
}
|
||||
|
||||
let [, name, params] = /@(.*?) (\(.*\))/g.exec(str)
|
||||
let [, name, params] = /@(.*?) (.*)/g.exec(str)
|
||||
return ({ wrap }) => wrap(postcss.atRule({ name, params }))
|
||||
})
|
||||
.reverse()
|
||||
|
|
|
|||
|
|
@ -239,6 +239,31 @@ it('should properly handle keyframes with multiple variants', async () => {
|
|||
`)
|
||||
})
|
||||
|
||||
test('custom addVariant with more complex media query params', () => {
|
||||
let config = {
|
||||
content: [
|
||||
{
|
||||
raw: html` <div class="magic:text-center"></div> `,
|
||||
},
|
||||
],
|
||||
plugins: [
|
||||
function ({ addVariant }) {
|
||||
addVariant('magic', '@media screen and (max-wdith: 600px)')
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
return run('@tailwind components;@tailwind utilities', config).then((result) => {
|
||||
return expect(result.css).toMatchFormattedCss(css`
|
||||
@media screen and (max-wdith: 600px) {
|
||||
.magic\:text-center {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
test('custom addVariant with nested media & format shorthand', () => {
|
||||
let config = {
|
||||
content: [
|
||||
|
|
@ -248,7 +273,7 @@ test('custom addVariant with nested media & format shorthand', () => {
|
|||
],
|
||||
plugins: [
|
||||
function ({ addVariant }) {
|
||||
addVariant('magic', '@supports (hover: hover) { @media (print) { &:disabled } }')
|
||||
addVariant('magic', '@supports (hover: hover) { @media print { &:disabled } }')
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -256,7 +281,7 @@ test('custom addVariant with nested media & format shorthand', () => {
|
|||
return run('@tailwind components;@tailwind utilities', config).then((result) => {
|
||||
return expect(result.css).toMatchFormattedCss(css`
|
||||
@supports (hover: hover) {
|
||||
@media (print) {
|
||||
@media print {
|
||||
.magic\:text-center:disabled {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue