From 0514b071d841e4e1ed4c52d615a3fe1a498f6cc0 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 25 Nov 2024 16:18:56 +0100 Subject: [PATCH 1/3] add failing test --- packages/tailwindcss/src/prefix.test.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/tailwindcss/src/prefix.test.ts b/packages/tailwindcss/src/prefix.test.ts index aa9e67b5a21c..27a71b6179f1 100644 --- a/packages/tailwindcss/src/prefix.test.ts +++ b/packages/tailwindcss/src/prefix.test.ts @@ -17,14 +17,35 @@ test('utilities must be prefixed', async () => { let compiler = await compile(input) // Prefixed utilities are generated - expect(compiler.build(['tw:underline', 'tw:hover:line-through', 'tw:custom'])) - .toMatchInlineSnapshot(` + expect( + compiler.build([ + 'tw:underline', + 'tw:hover:line-through', + 'tw:custom', + 'tw:group-hover:flex', + 'tw:peer-hover:flex', + ]), + ).toMatchInlineSnapshot(` ".tw\\:custom { color: red; } .tw\\:underline { text-decoration-line: underline; } + .tw\\:group-hover\\:flex { + &:is(:where(.tw\\:group):hover *) { + @media (hover: hover) { + display: flex; + } + } + } + .tw\\:peer-hover\\:flex { + &:is(:where(.tw\\:peer):hover ~ *) { + @media (hover: hover) { + display: flex; + } + } + } .tw\\:hover\\:line-through { &:hover { @media (hover: hover) { From b5ca19fac035f60834bb7470b03e27757a7a3843 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 25 Nov 2024 16:19:23 +0100 Subject: [PATCH 2/3] ensure `.group` and `.peer` are prefixed --- packages/tailwindcss/src/variants.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/tailwindcss/src/variants.ts b/packages/tailwindcss/src/variants.ts index a88f3d50660f..99cd20a455d4 100644 --- a/packages/tailwindcss/src/variants.ts +++ b/packages/tailwindcss/src/variants.ts @@ -518,8 +518,8 @@ export function createVariants(theme: Theme): Variants { // Name the group by appending the modifier to `group` class itself if // present. let variantSelector = variant.modifier - ? `:where(.group\\/${variant.modifier.value})` - : ':where(.group)' + ? `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}group\\/${variant.modifier.value})` + : `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}group)` let didApply = false @@ -570,8 +570,8 @@ export function createVariants(theme: Theme): Variants { // Name the peer by appending the modifier to `peer` class itself if // present. let variantSelector = variant.modifier - ? `:where(.peer\\/${variant.modifier.value})` - : ':where(.peer)' + ? `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}peer\\/${variant.modifier.value})` + : `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}peer)` let didApply = false From 7ecf3c95c385701482214d22709dd4ed9afe137a Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 25 Nov 2024 16:24:24 +0100 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ea16a6fc9c9..32272f11ec4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Ensure `.group` and `.peer` are prefixed when using the `prefix(…)` option ([#15174](https://github.com/tailwindlabs/tailwindcss/pull/15174)) ## [4.0.0-beta.2] - 2024-11-22