Skip to content

Commit d56d241

Browse files
authored
Ensure dashes are allowed in variant modifiers (#13303)
* sync package-lock.json * ensure dashes are allowed in variant modifiers * update changelog
1 parent 41e94eb commit d56d241

File tree

4 files changed

+32
-45
lines changed

4 files changed

+32
-45
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Split `:has` rules when using `experimental.optimizeUniversalDefaults` ([#12736](https://github.com/tailwindlabs/tailwindcss/pull/12736))
1515
- Sort arbitrary properties alphabetically across multiple class lists ([#12911](https://github.com/tailwindlabs/tailwindcss/pull/12911))
1616
- Add `mix-blend-plus-darker` utility ([#12923](https://github.com/tailwindlabs/tailwindcss/pull/12923))
17+
- Ensure dashes are allowed in variant modifiers ([#13303](https://github.com/tailwindlabs/tailwindcss/pull/13303))
1718

1819
## [3.4.1] - 2024-01-05
1920

package-lock.json

+9-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/defaultExtractor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function* buildRegExps(context) {
9696
regex.pattern([/@\[[^\s"'`]+\](\/[^\s"'`]+)?/, separator]),
9797

9898
// With variant modifier (e.g.: group-[..]/modifier)
99-
regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]\/\w+/, separator]),
99+
regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]\/[\w_-]+/, separator]),
100100

101101
regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/, separator]),
102102
regex.pattern([/[^\s"'`\[\\]+/, separator]),
@@ -105,7 +105,7 @@ function* buildRegExps(context) {
105105
// With quotes allowed
106106
regex.any([
107107
// With variant modifier (e.g.: group-[..]/modifier)
108-
regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s`]+\]\/\w+/, separator]),
108+
regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s`]+\]\/[\w_-]+/, separator]),
109109

110110
regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s`]+\]/, separator]),
111111
regex.pattern([/[^\s`\[\\]+/, separator]),

tests/variants.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ crosscheck(({ stable, oxide }) => {
283283
"Your custom variant `wtf-bbq` has an invalid format string. Make sure it's an at-rule or contains a `&` placeholder."
284284
)
285285
})
286+
287+
it('should allow modifiers with dashes', () => {
288+
let config = {
289+
content: [
290+
{
291+
raw: html`<div class="group-has-[[data-test=test]]/test-modifier:block"></div>`,
292+
},
293+
],
294+
plugins: [],
295+
}
296+
297+
return run('@tailwind utilities', config).then((result) => {
298+
return expect(result.css).toMatchFormattedCss(css`
299+
.group\/test-modifier:has([data-test='test'])
300+
.group-has-\[\[data-test\=test\]\]\/test-modifier\:block {
301+
display: block;
302+
}
303+
`)
304+
})
305+
})
286306
})
287307

288308
test('stacked peer variants', async () => {

0 commit comments

Comments
 (0)