Skip to content

Commit 7fcdd84

Browse files
authored
Allow whitespace around @source inline() arg (#19461)
## Summary Inspired by #19460, relaxes whitespace syntax around `@source inline(…):` ### Before ```css /* ❌ Error: `@source` paths must be quoted. */ @source inline( "underline" ); @source inline( "underline" ); ``` ### After ```css /* ✅ Generates the class names as normal. */ @source inline( "underline" ); @source inline( "underline" ); ``` ## Test plan Added tests to `packages/tailwindcss/src/index.test.ts`.
1 parent 1fbdd51 commit 7fcdd84

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Do not wrap `color-mix` in a `@supports` rule if one already exists ([#19450](https://github.com/tailwindlabs/tailwindcss/pull/19450))
13+
- Allow whitespace around `@source inline()` argument ([#19461](https://github.com/tailwindlabs/tailwindcss/pull/19461))
1314

1415
### Added
1516

packages/tailwindcss/src/index.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,6 +3802,44 @@ describe('@source', () => {
38023802

38033803
expect(build(['bg-red-500', 'bg-red-700'])).toMatchInlineSnapshot(`""`)
38043804
})
3805+
3806+
test('works with whitespace around the argument', async () => {
3807+
let { build } = await compile(
3808+
css`
3809+
/* prettier-ignore */
3810+
@source inline( "underline" );
3811+
@tailwind utilities;
3812+
`,
3813+
{ base: '/root' },
3814+
)
3815+
3816+
expect(build([])).toMatchInlineSnapshot(`
3817+
".underline {
3818+
text-decoration-line: underline;
3819+
}
3820+
"
3821+
`)
3822+
})
3823+
3824+
test('works with newlines around the argument', async () => {
3825+
let { build } = await compile(
3826+
css`
3827+
/* prettier-ignore */
3828+
@source inline(
3829+
"underline"
3830+
);
3831+
@tailwind utilities;
3832+
`,
3833+
{ base: '/root' },
3834+
)
3835+
3836+
expect(build([])).toMatchInlineSnapshot(`
3837+
".underline {
3838+
text-decoration-line: underline;
3839+
}
3840+
"
3841+
`)
3842+
})
38053843
})
38063844
})
38073845

packages/tailwindcss/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ async function parseCss(
274274

275275
if (path[0] === 'i' && path.startsWith('inline(')) {
276276
inline = true
277-
path = path.slice(7, -1)
277+
path = path.slice(7, -1).trim()
278278
}
279279

280280
if (

0 commit comments

Comments
 (0)