Skip to content

Conversation

@RobinMalfait
Copy link
Member

This PR fixes an issue where a CSS rule with a selector that contains multiple selectors lost everything but the last selector.

While testing the npx @tailwindcss/upgrade codemods on real world projects, I noticed that we lost one of the selectors in the docker/docs repository.

diff --git a/assets/css/toc.css b/assets/css/toc.css
index 91ff92d7cd..3b2432e913 100644
--- a/assets/css/toc.css
+++ b/assets/css/toc.css
@@ -2,7 +2,7 @@
   #TableOfContents {
     .toc a {
       @apply block max-w-full truncate py-1 pl-2 hover:font-medium hover:no-underline;
-      &[aria-current="true"],
+      
       &:hover {
         @apply border-l-2 border-l-gray-light bg-gradient-to-r from-gray-light-100 font-medium text-black dark:border-l-gray-dark dark:from-gray-dark-200 dark:text-white;
       }

This PR fixes the issue by not overriding the node.selector internally with the last selector we handled. Instead, we let the selector parser handle it entirely.

@RobinMalfait RobinMalfait force-pushed the fix/prevent-losing-attribute-selectors branch from 6c34166 to 03531ff Compare September 25, 2024 15:07
This was updating the `node.selector` when we handled the selector, but
there could be multiple selectors. This means that the last one wins and
the previous selectors were removed.

The selector parser updates selectors in place if you mutate them. We
can just use that as-in.
@RobinMalfait RobinMalfait force-pushed the fix/prevent-losing-attribute-selectors branch from 03531ff to 37cd738 Compare September 25, 2024 15:34
@RobinMalfait RobinMalfait merged commit 8bbdb57 into next Sep 25, 2024
@RobinMalfait RobinMalfait deleted the fix/prevent-losing-attribute-selectors branch September 25, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants