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
This commit is contained in:
Robin Malfait 2025-10-15 11:50:02 +02:00 committed by GitHub
parent 22858ac4ae
commit de6b54c307
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View File

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow named groups in combination with `not-*`, `has-*`, and `in-*` ([#19100](https://github.com/tailwindlabs/tailwindcss/pull/19100))
- Prevent important utilities from affecting other utilities ([#19110](https://github.com/tailwindlabs/tailwindcss/pull/19110))
- Dont index into strings with the `theme(…)` function ([#19111](https://github.com/tailwindlabs/tailwindcss/pull/19111))
- Fix parsing issue when `\t` is used in at-rules ([#19130](https://github.com/tailwindlabs/tailwindcss/pull/19130))
- Upgrade: Canonicalize utilities containing `0` values ([#19095](https://github.com/tailwindlabs/tailwindcss/pull/19095))
## [4.1.14] - 2025-10-01

View File

@ -723,6 +723,26 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
).toEqual([{ kind: 'at-rule', name: '@charset', params: '"UTF-8"', nodes: [] }])
})
it.each([
[' '], // space
[' '], // multiple spaces
['\t'], // tab
[' \t'], // space + tab
['\t '], // tab + space
['\t\t'], // multiple tabs
['\n'], // newline
[' \n'], // space + newline
['\n '], // newline + space
['\n\n'], // multiple newlines
['\r\n'], // windows newline
[' \r\n'], // space + windows newline
['\r\n '], // windows newline + space
])('should parse an at-rule with whitespace %s in the params', (whitespace) => {
expect(parse(`@apply${whitespace}bg-red-500;`)).toEqual([
{ kind: 'at-rule', name: '@apply', params: 'bg-red-500', nodes: [] },
])
})
it('should parse an at-rule without a block or semicolon', () => {
expect(
parse(`

View File

@ -571,7 +571,7 @@ export function parseAtRule(buffer: string, nodes: AstNode[] = []): AtRule {
// behavior if necessary.
for (let i = 5 /* '@page'.length */; i < buffer.length; i++) {
let currentChar = buffer.charCodeAt(i)
if (currentChar === SPACE || currentChar === OPEN_PAREN) {
if (currentChar === SPACE || currentChar === TAB || currentChar === OPEN_PAREN) {
name = buffer.slice(0, i)
params = buffer.slice(i)
break