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

Ensure nested selectors using &:hover work #246

Merged
merged 2 commits into from
Feb 14, 2022
Merged

Conversation

RobinMalfait
Copy link
Contributor

This PR will fix an issue where nested configuration in the tailwind.config.js didn't get the correct selector.

E.g.:

theme: {
  extend: {
    typography: {
      DEFAULT: {
        css: {
          a: {
            color: '#888',
            '&:hover': {
              color: '#ff0000',
            },
          },
        },
      },
    },
  },
},

This generated the incorrect css:

.prose a {
  color: #888;
  text-decoration: underline;
  font-weight: 500;
}

:where(.prose a:hover):not(:where([class~="not-prose"] *)) {
  color: #FF0000;
}

This means that the non-hover version still has higher specificity. The output we want is this:

.prose :where(a):not(:where([class~='not-prose'] *)) {
  color: #888;
  text-decoration: underline;
  font-weight: 500;
}

.prose :where(a):not(:where([class~='not-prose'] *)):hover {
  color: #ff0000;
}

Fixes: #231

@vercel
Copy link

vercel bot commented Feb 14, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tailwindlabs/tailwindcss-typography/2QqvrHaLztt8VHqLYjzEw2xawtqS
✅ Preview: https://tailwindcss-typography-git-fix-nesting-tailwindlabs.vercel.app

@jacobdalamb
Copy link

This breaks dark mode css customization with prose class.

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.

a "&:hover" not being applied when extending config
2 participants