Skip to content

Commit 1bdc906

Browse files
Allow hyphen character in regex pattern to use support queries as is (tailwindlabs#13596)
* Allow hyphen character in regex pattern to use support queries as is * Update variants.test.ts --------- Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
1 parent 07d977e commit 1bdc906

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

packages/tailwindcss/src/variants.test.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,15 @@ test('sorting `min` and `max` should sort by unit, then by value, then alphabeti
12881288

12891289
test('supports', () => {
12901290
expect(
1291-
run(['supports-gap:grid', 'supports-[display:grid]:flex', 'supports-[selector(A_>_B)]:flex']),
1291+
run([
1292+
'supports-gap:grid',
1293+
'supports-[display:grid]:flex',
1294+
'supports-[selector(A_>_B)]:flex',
1295+
'supports-[font-format(opentype)]:grid',
1296+
'supports-[(display:grid)_and_font-format(opentype)]:grid',
1297+
'supports-[font-tech(color-COLRv1)]:flex',
1298+
'supports-[--test]:flex',
1299+
]),
12921300
).toMatchInlineSnapshot(`
12931301
"@supports (gap: var(--tw)) {
12941302
.supports-gap\\:grid {
@@ -1306,6 +1314,30 @@ test('supports', () => {
13061314
.supports-\\[selector\\(A_\\>_B\\)\\]\\:flex {
13071315
display: flex;
13081316
}
1317+
}
1318+
1319+
@supports font-format(opentype) {
1320+
.supports-\\[font-format\\(opentype\\)\\]\\:grid {
1321+
display: grid;
1322+
}
1323+
}
1324+
1325+
@supports (display: grid) and font-format(opentype) {
1326+
.supports-\\[\\(display\\:grid\\)_and_font-format\\(opentype\\)\\]\\:grid {
1327+
display: grid;
1328+
}
1329+
}
1330+
1331+
@supports font-tech(color-COLRv1) {
1332+
.supports-\\[font-tech\\(color-COLRv1\\)\\]\\:flex {
1333+
display: flex;
1334+
}
1335+
}
1336+
1337+
@supports (--test: var(--tw)) {
1338+
.supports-\\[--test\\]\\:flex {
1339+
display: flex;
1340+
}
13091341
}"
13101342
`)
13111343
})

packages/tailwindcss/src/variants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export function createVariants(theme: Theme): Variants {
384384
// When `supports-[...]:flex` is used, with `not()`, `and()` or
385385
// `selector()`, then we know that want to use this directly as the
386386
// supports condition as-is.
387-
if (/^\w*\s*\(/.test(value)) {
387+
if (/^[\w-]*\s*\(/.test(value)) {
388388
// Chrome has a bug where `(condition1)or(condition2)` is not valid, but
389389
// `(condition1) or (condition2)` is supported.
390390
let query = value.replace(/\b(and|or|not)\b/g, ' $1 ')

0 commit comments

Comments
 (0)