Skip to content

Commit de6b54c

Browse files
authored
Fix parsing issue when \t is used in at-rules (#19130)
This PR fixes an issue where an at-rule that used `@name\tparams` didn't properly parse because we didn't properly handle `\t`. ## Test plan 1. Added failing tests 2. Made them pass Fixes: #19127
1 parent 22858ac commit de6b54c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- Allow named groups in combination with `not-*`, `has-*`, and `in-*` ([#19100](https://github.com/tailwindlabs/tailwindcss/pull/19100))
2020
- Prevent important utilities from affecting other utilities ([#19110](https://github.com/tailwindlabs/tailwindcss/pull/19110))
2121
- Don’t index into strings with the `theme(…)` function ([#19111](https://github.com/tailwindlabs/tailwindcss/pull/19111))
22+
- Fix parsing issue when `\t` is used in at-rules ([#19130](https://github.com/tailwindlabs/tailwindcss/pull/19130))
2223
- Upgrade: Canonicalize utilities containing `0` values ([#19095](https://github.com/tailwindlabs/tailwindcss/pull/19095))
2324

2425
## [4.1.14] - 2025-10-01

packages/tailwindcss/src/css-parser.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,26 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
723723
).toEqual([{ kind: 'at-rule', name: '@charset', params: '"UTF-8"', nodes: [] }])
724724
})
725725

726+
it.each([
727+
[' '], // space
728+
[' '], // multiple spaces
729+
['\t'], // tab
730+
[' \t'], // space + tab
731+
['\t '], // tab + space
732+
['\t\t'], // multiple tabs
733+
['\n'], // newline
734+
[' \n'], // space + newline
735+
['\n '], // newline + space
736+
['\n\n'], // multiple newlines
737+
['\r\n'], // windows newline
738+
[' \r\n'], // space + windows newline
739+
['\r\n '], // windows newline + space
740+
])('should parse an at-rule with whitespace %s in the params', (whitespace) => {
741+
expect(parse(`@apply${whitespace}bg-red-500;`)).toEqual([
742+
{ kind: 'at-rule', name: '@apply', params: 'bg-red-500', nodes: [] },
743+
])
744+
})
745+
726746
it('should parse an at-rule without a block or semicolon', () => {
727747
expect(
728748
parse(`

packages/tailwindcss/src/css-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ export function parseAtRule(buffer: string, nodes: AstNode[] = []): AtRule {
571571
// behavior if necessary.
572572
for (let i = 5 /* '@page'.length */; i < buffer.length; i++) {
573573
let currentChar = buffer.charCodeAt(i)
574-
if (currentChar === SPACE || currentChar === OPEN_PAREN) {
574+
if (currentChar === SPACE || currentChar === TAB || currentChar === OPEN_PAREN) {
575575
name = buffer.slice(0, i)
576576
params = buffer.slice(i)
577577
break

0 commit comments

Comments
 (0)