Skip to content

Commit ebfee41

Browse files
quotes are technically optional, let's account for that
Co-Authored-By: Jordan Pittman <[email protected]>
1 parent 4fe4301 commit ebfee41

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

integrations/upgrade/js-config.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,12 @@ test(
992992
// Automatically handled by bare values
993993
foo: 'foo="true"',
994994
995+
// Quotes are optional in CSS for these kinds of attribute
996+
// selectors
997+
bar: 'bar=true',
998+
995999
// Not automatically handled by bare values because names differ
996-
bar: 'baz="true"',
1000+
baz: 'qux="true"',
9971001
9981002
// Completely custom
9991003
asc: 'sort="ascending"',
@@ -1018,7 +1022,7 @@ test(
10181022
--- src/input.css ---
10191023
@import 'tailwindcss';
10201024
1021-
@custom-variant aria-bar (&[aria-baz="true"]);
1025+
@custom-variant aria-baz (&[aria-qux="true"]);
10221026
@custom-variant aria-asc (&[aria-sort="ascending"]);
10231027
@custom-variant aria-desc (&[aria-sort="descending"]);
10241028

packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async function migrateTheme(
145145
for (let [key, value] of Object.entries(resolvedConfig.theme.aria ?? {})) {
146146
// Will be handled by bare values if the names match.
147147
// E.g.: `aria-foo:flex` should produce `[aria-foo="true"]`
148-
if (new RegExp(`^${key}=['"]true['"]$`).test(`${value}`)) continue
148+
if (new RegExp(`^${key}=(['"]?)true\\1$`).test(`${value}`)) continue
149149

150150
// Create custom variant
151151
variants.set(`aria-${key}`, `&[aria-${value}]`)

0 commit comments

Comments
 (0)