Skip to content

Erroneous ::before selector can be generated with darkMode: 'class' #280

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

Closed
wongjn opened this issue Aug 13, 2022 · 1 comment · Fixed by #281
Closed

Erroneous ::before selector can be generated with darkMode: 'class' #280

wongjn opened this issue Aug 13, 2022 · 1 comment · Fixed by #281
Assignees

Comments

@wongjn
Copy link

wongjn commented Aug 13, 2022

What version of @tailwindcss/typography are you using?

3.1.8

What version of Node.js are you using?

16

What browser are you using?

Chrome

What operating system are you using?

WSL

Reproduction repository

https://play.tailwindcss.com/SQ9TLTgQqn

Describe your issue

Discussed in tailwindlabs/tailwindcss#9092

Seems to be a bug in @tailwindcss/typography when the following criteria are met:

  • multiple ::before rules in the same selector (in this case, the ol li::before,ul li::before)
  • darkMode set to class
  • dark:prose class exists

This results in an erroneous rule as the following:

.dark .dark\:prose :where(ol li,ul li):not(:where([class~="not-prose"] *))::before,::before {
  /* … */
}

In particular, the lone ::before selector at the end (minimum reproduction Tailwind Play).

Workaround

As a workaround, one can slightly tweak the config CSS to be like the following:

-  'ol li::before,ul li::before': {
-    // …
+  'ol li, ul li': {
+    '&::before': {
+      // …
+    },
   },

Tailwind Play of it working

Originally posted by @wongjn in tailwindlabs/tailwindcss#9092 (comment)

@thecrypticace
Copy link
Contributor

Hey, thanks for the report (and the workaround!) — this one was an interesting one to figure out. I've merged the fix for this and it'll be in our next tagged release. It should also be in our insiders build in a few minutes if you want to test it out before the next release: npm install @tailwindcss/typography@insiders

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 a pull request may close this issue.

2 participants