From 970ff521621f820dc08f57d998c269096fba7176 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 21 Oct 2025 16:06:02 -0400 Subject: [PATCH 1/2] Discard candidates with an empty data type --- packages/tailwindcss/src/candidate.test.ts | 8 ++++++++ packages/tailwindcss/src/candidate.ts | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/tailwindcss/src/candidate.test.ts b/packages/tailwindcss/src/candidate.test.ts index 3d4aa983b2a0..53d21dda695f 100644 --- a/packages/tailwindcss/src/candidate.test.ts +++ b/packages/tailwindcss/src/candidate.test.ts @@ -1776,6 +1776,14 @@ it('should not parse compound group with a non-compoundable variant', () => { expect(run('group-*:flex', { utilities, variants })).toMatchInlineSnapshot(`[]`) }) +it('empty data types are invalid', () => { + let utilities = new Utilities() + utilities.functional('bg', () => []) + let variants = new Variants() + + expect(run('bg-[:foo]', { utilities, variants })).toMatchInlineSnapshot(`[]`) +}) + it('should parse a variant containing an arbitrary string with unbalanced parens, brackets, curlies and other quotes', () => { let utilities = new Utilities() utilities.static('flex', () => []) diff --git a/packages/tailwindcss/src/candidate.ts b/packages/tailwindcss/src/candidate.ts index c081c3b472b8..fa8cd3047e6d 100644 --- a/packages/tailwindcss/src/candidate.ts +++ b/packages/tailwindcss/src/candidate.ts @@ -554,7 +554,7 @@ export function* parseCandidate(input: string, designSystem: DesignSystem): Iter if (!isValidArbitrary(arbitraryValue)) continue // Extract an explicit typehint if present, e.g. `bg-[color:var(--my-var)])` - let typehint = '' + let typehint: string | null = null for (let i = 0; i < arbitraryValue.length; i++) { let code = arbitraryValue.charCodeAt(i) @@ -580,6 +580,8 @@ export function* parseCandidate(input: string, designSystem: DesignSystem): Iter continue } + if (typehint === '') continue + candidate.value = { kind: 'arbitrary', dataType: typehint || null, From f261c6ec08e3bfe184c8875ddbeddeaff2bb3bed Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 21 Oct 2025 16:49:30 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5292d918cc87..375288258a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - _Experimental_: Add `@container-size` utility ([#18901](https://github.com/tailwindlabs/tailwindcss/pull/18901)) +### Fixed + +- Discard candidates with an empty data type ([#19172](https://github.com/tailwindlabs/tailwindcss/pull/19172)) + ## [4.1.15] - 2025-10-20 ### Fixed