Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don't generate utilities when a modifier is used that would otherwise be silently ignored (e.g. `rounded-sm/[5]`, `shadow-sm/foo`, `stroke-2/50`) ([#20419](https://github.com/tailwindlabs/tailwindcss/pull/20419))
- Only normalize top-level `and`, `or`, and `not` keywords in `supports-[…]` variants (e.g. `selector(a: not (.foo))` → `selector(a:not(.foo))`) ([#20420](https://github.com/tailwindlabs/tailwindcss/pull/20420))
- Don't warn about Angular's `::ng-deep` and `:host-context()` when optimizing CSS ([#20434](https://github.com/tailwindlabs/tailwindcss/pull/20434))
- Don't generate CSS for candidates containing an empty additional modifier (e.g. `bg-red-500/50/` and `group-hover/foo//bar:flex`) ([#20466](https://github.com/tailwindlabs/tailwindcss/pull/20466))

## [4.3.3] - 2026-07-16

Expand Down
15 changes: 15 additions & 0 deletions packages/tailwindcss/src/candidate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ it('should not parse functional utilities with multiple modifiers', () => {
utilities.functional('bg', () => [])

expect(run('bg-red-1/2/3', { utilities })).toMatchInlineSnapshot(`[]`)
expect(run('bg-red-500/50/', { utilities })).toMatchInlineSnapshot(`[]`)
expect(run('bg-red-500/50//foo', { utilities })).toMatchInlineSnapshot(`[]`)
})

it('should parse a utility with an arbitrary value', () => {
Expand Down Expand Up @@ -1416,6 +1418,19 @@ it('should parse a functional variant with a modifier', () => {
`)
})

it('should not parse variants with multiple modifiers', () => {
let utilities = new Utilities()
utilities.static('flex', () => [])

let variants = new Variants()
variants.static('hover', () => {})
variants.compound('group', Compounds.StyleRules, () => {})

expect(run('group-hover/foo:flex', { utilities, variants })).toHaveLength(1)
expect(run('group-hover/foo/:flex', { utilities, variants })).toEqual([])
expect(run('group-hover/foo//bar:flex', { utilities, variants })).toEqual([])
})

it('should parse a functional variant starting with @', () => {
let utilities = new Utilities()
utilities.static('flex', () => [])
Expand Down
30 changes: 16 additions & 14 deletions packages/tailwindcss/src/candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ export function* parseCandidate(input: string, designSystem: DesignSystem): Iter
}
}

// If there's more than one modifier, the utility is invalid.
//
// E.g.:
//
// - `bg-red-500/50/50`
let parts = segment(base, '/')
if (parts.length > 2) return

// Figure out the new base and the modifier segment if present.
//
// E.g.:
Expand All @@ -381,14 +389,7 @@ export function* parseCandidate(input: string, designSystem: DesignSystem): Iter
// ^^^^^^^^^^ -> Base without modifier
// ^^ -> Modifier segment
// ```
let [baseWithoutModifier, modifierSegment = null, additionalModifier] = segment(base, '/')

// If there's more than one modifier, the utility is invalid.
//
// E.g.:
//
// - `bg-red-500/50/50`
if (additionalModifier) return
let [baseWithoutModifier, modifierSegment = null] = parts

let parsedModifier = modifierSegment === null ? null : parseModifier(modifierSegment)

Expand Down Expand Up @@ -707,17 +708,18 @@ export function parseVariant(variant: string, designSystem: DesignSystem): Varia

// Static, functional and compound variants
{
// group-hover/group-name
// ^^^^^^^^^^^ -> Variant without modifier
// ^^^^^^^^^^ -> Modifier
let [variantWithoutModifier, modifier = null, additionalModifier] = segment(variant, '/')

// If there's more than one modifier, the variant is invalid.
//
// E.g.:
//
// - `group-hover/foo/bar`
if (additionalModifier) return null
let parts = segment(variant, '/')
if (parts.length > 2) return null

// group-hover/group-name
// ^^^^^^^^^^^ -> Variant without modifier
// ^^^^^^^^^^ -> Modifier
let [variantWithoutModifier, modifier = null] = parts

let roots = findRoots(variantWithoutModifier, (root) => {
return designSystem.variants.has(root)
Expand Down