Skip to content

Commit dadf2b8

Browse files
committed
simplify: move the modifier _before_ parsing sub-variants
That way `not-group-hover/name:flex` is actually parsed as a `not` and a `group-hover/name` instead of a `not/name` and `group-hover`.
1 parent 3a32bff commit dadf2b8

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

packages/tailwindcss/src/candidate.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -806,23 +806,16 @@ export function parseVariant(variant: string, designSystem: DesignSystem): Varia
806806
case 'compound': {
807807
if (value === null) return null
808808

809-
let subVariant = designSystem.parseVariant(value)
810-
if (subVariant === null) return null
811-
812809
// Forward the modifier of the `not` and `has` variants to its
813810
// subVariant. This allows for `not-group-hover/name:flex` to work.
814-
if (modifier && (root === 'not' || root === 'has') && 'modifier' in subVariant) {
815-
// Forward modifiers to the subVariant
816-
let parsedModifier = parseModifier(modifier)
817-
if (parsedModifier !== null) {
818-
// Can't mutate directly because the `subVariant` is a shared
819-
// object and then `group-hover` would be equivalent to
820-
// `group-hover/name` which would be incorrect.
821-
subVariant = { ...subVariant, modifier: parsedModifier }
822-
modifier = null
823-
}
811+
if (modifier && (root === 'not' || root === 'has')) {
812+
value = `${value}/${modifier}`
813+
modifier = null
824814
}
825815

816+
let subVariant = designSystem.parseVariant(value)
817+
if (subVariant === null) return null
818+
826819
// These two variants must be compatible when compounded
827820
if (!designSystem.variants.compoundsWith(root, subVariant)) return null
828821

0 commit comments

Comments
 (0)