8000 Move modifier of `not-*`, `has-*`, and `in-*` variant to sub variant by RobinMalfait · Pull Request #19100 · tailwindlabs/tailwindcss · GitHub
Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
forward modifier of not and has variants to their subVariant
  • Loading branch information
RobinMalfait committed Oct 9, 2025
commit c4847c083a012ef4829337619e209d4410fc6b3b
14 changes: 14 additions & 0 deletions packages/tailwindcss/src/candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,20 @@ export function parseVariant(variant: string, designSystem: DesignSystem): Varia
let subVariant = designSystem.parseVariant(value)
if (subVariant === null) return null

// Forward the modifier of the `not` and `has` variants to its
// subVariant. This allows for `not-group-hover/name:flex` to work.
if (modifier && (root === 'not' || root === 'has') && 'modifier' in subVariant) {
// Forward modifiers to the subVariant
let parsedModifier = parseModifier(modifier)
if (parsedModifier !== null) {
// Can't mutate directly because the `subVariant` is a shared
// object and then `group-hover` would be equivalent to
// `group-hover/name` which would be incorrect.
subVariant = { ...subVariant, modifier: parsedModifier }
modifier = null
}
}

// These two variants must be compatible when compounded
if (!designSystem.variants.compoundsWith(root, subVariant)) return null

Expand Down