Skip to content

Commit 9c59b07

Browse files
authored
Ensure -- is allowed inside candidates (tailwindlabs#16972)
This PR fixes an issue where named utilities that contain double dashes `--` are not extracted correctly. Some people use `--` in the middle of the utility to create some form of namespaced utility. Given this input: ```js let x = 'foo--bar' ``` The extracted candidates before this change: ```js [ "let", "x", "--bar" ] ``` The extracted candidates after this change: ```js [ "let", "x", "foo--bar", "--bar" ] ``` The reason `--bar` is still extracted in both cases is because of the CSS variable machine. We could improve its extraction by checking its boundary characters but that's a different issue. For now, the important thing is that `foo--bar` was extracted. # Test plan 1. Added new test 2. Existing tests pass
1 parent 1638b16 commit 9c59b07

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- _Experimental_: Add `user-valid` and `user-invalid` variants ([#12370](https://github.com/tailwindlabs/tailwindcss/pull/12370))
1818
- _Experimental_: Add `wrap-anywhere`, `wrap-break-word`, and `wrap-normal` utilities ([#12128](https://github.com/tailwindlabs/tailwindcss/pull/12128))
1919

20+
### Fixed
21+
22+
- Ensure classes containing `--` are extracted correctly ([#16972](https://github.com/tailwindlabs/tailwindcss/pull/16972))
23+
2024
## [4.0.10] - 2025-03-05
2125

2226
### Added
@@ -41,7 +45,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4145
- Removed `max-w-auto` and `max-h-auto` utilities as they generate invalid CSS ([#16917](https://github.com/tailwindlabs/tailwindcss/pull/16917))
4246
- Replaced the existing candidate extractor with a brand new extractor to improve maintainability, correctness, and performance ([#16306](https://github.com/tailwindlabs/tailwindcss/pull/16306))
4347

44-
4548
## [4.0.9] - 2025-02-25
4649

4750
### Fixed

crates/oxide/src/extractor/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ mod tests {
297297
("flex block", vec!["flex", "block"]),
298298
// Simple utility with dashes
299299
("items-center", vec!["items-center"]),
300+
("items--center", vec!["items--center"]),
300301
// Simple utility with numbers
301302
("px-2.5", vec!["px-2.5"]),
302303
// Arbitrary properties

crates/oxide/src/extractor/named_utility_machine.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ impl Machine for NamedUtilityMachine {
171171
// ^ Invalid
172172
// E.g.: `flex-2`
173173
// ^ Valid
174-
Class::AlphaLower | Class::AlphaUpper | Class::Number => {
174+
// E.g.: `foo--bar`
175+
// ^ Valid
176+
Class::AlphaLower | Class::AlphaUpper | Class::Number | Class::Dash => {
175177
cursor.advance();
176178
}
177179

@@ -388,6 +390,8 @@ mod tests {
388390
("a", vec!["a"]),
389391
// With dashes
390392
("items-center", vec!["items-center"]),
393+
// With double dashes
394+
("items--center", vec!["items--center"]),
391395
// With numbers
392396
("px-5", vec!["px-5"]),
393397
("px-2.5", vec!["px-2.5"]),

crates/oxide/src/extractor/utility_machine.rs

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ mod tests {
219219
("flex! block", vec!["flex!", "block"]),
220220
// With dashes
221221
("items-center", vec!["items-center"]),
222+
("items--center", vec!["items--center"]),
222223
// Inside a string
223224
("'flex'", vec!["flex"]),
224225
// Multiple utilities

0 commit comments

Comments
 (0)