Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly rewrites classnames with :state in name #79

Open
mitchellklijs opened this issue Jun 27, 2023 · 0 comments · May be fixed by #80
Open

Incorrectly rewrites classnames with :state in name #79

mitchellklijs opened this issue Jun 27, 2023 · 0 comments · May be fixed by #80

Comments

@mitchellklijs
Copy link

In CSS, classnames may have colons (:). Tailwind CSS uses a state followed by a colon to express a utility class that only applies when that state is active (see https://tailwindcss.com/docs/hover-focus-and-other-states). An example could be: hover:border-red. This would apply the style for border-red only when the element is hovered.

The example (hover:border-red) would have the following generated CSS (by Tailwind):

.hover:border-red:hover {border: red;}

This is rewritten by the addon to:

.hover:border-red:hover, .hover:border-red.pseudo-hover, .pseudo-hover .hover:border-red {border: red;}

This rewrite is correct. However, when you combine two states, for example focus:hover:border-red. The translation is incorrect.

The example class translates to the following generated CSS (by Tailwind):

.focus:hover:border-red:hover:focus {border: red;}

The addon rewrites this to:

.focus:hover:border-red:hover:focus, .focus.pseudo-hover:border-red.pseudo-hover.pseudo-focus, .pseudo-hover.pseudo-hover.pseudo-focus .focus:border-red {border:red;}

Which is incorrect. The first :hover is also replaced by pseudo-hover.

The correct output would be:

.focus:hover:border-red:hover:focus, .focus:hover:border-red.pseudo-hover.pseudo-focus, .pseudo-hover.pseudo-focus .focus:hover:border-red {border:red;}

In short; when classnames have a colon followed by a state name in them, they are incorrectly replaced with the pseudo-states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant