Skip to content

Commit b069d7a

Browse files
Disable padding in @source inline(…) brace expansion (#17491)
The padding code we had was incorrect as it would always pad on the largest string representation. So for an input like this: ``` @source inline("z-{10..100..10}"); ``` It would create the following candidates: - `z-010` - `z-020` - `z-030` - `z-040` - `z-050` - `z-060` - `z-070` - `z-060` - `z-070` - `z-100` Instead of fixing the padding logic we realized that Tailwind utilities don't need padding at all so this PR removes this feature ## Test plan - Added the following to the Vite playground: `@source inline("z-{10..100..10}");` - Ensure it works: ![image](https://github.com/user-attachments/assets/f4714729-4ef7-4678-a531-70b471e75e6e)
1 parent 8f631d0 commit b069d7a

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Disable padding in `@source inline(…)` brace expansion ([#17491](https://github.com/tailwindlabs/tailwindcss/pull/17491))
1113

1214
## [4.1.0] - 2025-04-01
1315

packages/tailwindcss/src/utils/brace-expansion.test.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ describe('expand(…)', () => {
1414
['a/{0..5}/b', ['a/0/b', 'a/1/b', 'a/2/b', 'a/3/b', 'a/4/b', 'a/5/b']],
1515
['a/{-5..0}/b', ['a/-5/b', 'a/-4/b', 'a/-3/b', 'a/-2/b', 'a/-1/b', 'a/0/b']],
1616
['a/{0..-5}/b', ['a/0/b', 'a/-1/b', 'a/-2/b', 'a/-3/b', 'a/-4/b', 'a/-5/b']],
17-
18-
// Numeric range with padding
19-
['a/{00..05}/b', ['a/00/b', 'a/01/b', 'a/02/b', 'a/03/b', 'a/04/b', 'a/05/b']],
2017
[
21-
'a{001..9}b',
22-
['a001b', 'a002b', 'a003b', 'a004b', 'a005b', 'a006b', 'a007b', 'a008b', 'a009b'],
18+
'a/{0..10..5}/b',
19+
['a/0/b', 'a/5/b', 'a/10/b'],
20+
['a/{10..0..5}/b', ['a/10/b', 'a/5/b', 'a/0/b']],
2321
],
2422

23+
// Numeric range with padding (we do not support padding)
24+
['a/{00..05}/b', ['a/0/b', 'a/1/b', 'a/2/b', 'a/3/b', 'a/4/b', 'a/5/b']],
25+
['a{001..9}b', ['a1b', 'a2b', 'a3b', 'a4b', 'a5b', 'a6b', 'a7b', 'a8b', 'a9b']],
26+
2527
// Numeric range with step
2628
['a/{0..5..2}/b', ['a/0/b', 'a/2/b', 'a/4/b']],
2729
[

packages/tailwindcss/src/utils/brace-expansion.ts

-9
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ function expandSequence(seq: string): string[] {
7272
let startNum = parseInt(start, 10)
7373
let endNum = parseInt(end, 10)
7474

75-
// Determine padding length (if any) but don't count the sign as length
76-
let padLength = Math.max(start.replace(/^-/, '').length, end.replace(/^-/, '').length)
77-
7875
if (step === undefined) {
7976
step = startNum <= endNum ? 1 : -1
8077
}
@@ -84,17 +81,11 @@ function expandSequence(seq: string): string[] {
8481
if (step > 0) {
8582
for (let i = startNum; i <= endNum; i += step) {
8683
let numStr = i.toString()
87-
if (numStr.length < padLength) {
88-
numStr = numStr.padStart(padLength, '0')
89-
}
9084
result.push(numStr)
9185
}
9286
} else {
9387
for (let i = startNum; i >= endNum; i += step) {
9488
let numStr = i.toString()
95-
if (numStr.length < padLength) {
96-
numStr = numStr.padStart(padLength, '0')
97-
}
9889
result.push(numStr)
9990
}
10091
}

0 commit comments

Comments
 (0)