Skip to content

Disable padding in @source inline(…) brace expansion #17491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Disable padding in `@source inline(…)` brace expansion ([#17491](https://github.com/tailwindlabs/tailwindcss/pull/17491))

## [4.1.0] - 2025-04-01

Expand Down
12 changes: 7 additions & 5 deletions packages/tailwindcss/src/utils/brace-expansion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ describe('expand(…)', () => {
['a/{0..5}/b', ['a/0/b', 'a/1/b', 'a/2/b', 'a/3/b', 'a/4/b', 'a/5/b']],
['a/{-5..0}/b', ['a/-5/b', 'a/-4/b', 'a/-3/b', 'a/-2/b', 'a/-1/b', 'a/0/b']],
['a/{0..-5}/b', ['a/0/b', 'a/-1/b', 'a/-2/b', 'a/-3/b', 'a/-4/b', 'a/-5/b']],

// Numeric range with padding
['a/{00..05}/b', ['a/00/b', 'a/01/b', 'a/02/b', 'a/03/b', 'a/04/b', 'a/05/b']],
[
'a{001..9}b',
['a001b', 'a002b', 'a003b', 'a004b', 'a005b', 'a006b', 'a007b', 'a008b', 'a009b'],
'a/{0..10..5}/b',
['a/0/b', 'a/5/b', 'a/10/b'],
['a/{10..0..5}/b', ['a/10/b', 'a/5/b', 'a/0/b']],
],

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

// Numeric range with step
['a/{0..5..2}/b', ['a/0/b', 'a/2/b', 'a/4/b']],
[
Expand Down
9 changes: 0 additions & 9 deletions packages/tailwindcss/src/utils/brace-expansion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ function expandSequence(seq: string): string[] {
let startNum = parseInt(start, 10)
let endNum = parseInt(end, 10)

// Determine padding length (if any) but don't count the sign as length
let padLength = Math.max(start.replace(/^-/, '').length, end.replace(/^-/, '').length)

if (step === undefined) {
step = startNum <= endNum ? 1 : -1
}
Expand All @@ -84,17 +81,11 @@ function expandSequence(seq: string): string[] {
if (step > 0) {
for (let i = startNum; i <= endNum; i += step) {
let numStr = i.toString()
if (numStr.length < padLength) {
numStr = numStr.padStart(padLength, '0')
}
result.push(numStr)
}
} else {
for (let i = startNum; i >= endNum; i += step) {
let numStr = i.toString()
if (numStr.length < padLength) {
numStr = numStr.padStart(padLength, '0')
}
result.push(numStr)
}
}
Expand Down