question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TW 3.2.0 regression: `@apply` incorrectly modifies selectors containing pseudo-classes

See original GitHub issue

What version of Tailwind CSS are you using?

Appears in 3.2.0, also occurs in 3.2.1 (current latest)

What build tool (or framework if it abstracts the build tool) are you using?

“ember-cli-postcss”: “^8.2.0”, “postcss”: “^8.4.18”,

What version of Node.js are you using?

v16.17.0

What browser are you using?

N/A

What operating system are you using?

ubuntu

Reproduction URL

I attempted to create a Tailwind Play link, but couldn’t figure out how to add tailwind nesting plugin 😦 The plugins property in config expects an array, but the docs on tailwind website has plugins as an object!

Here it is, if you can get tailwindcss/nesting working… https://play.tailwindcss.com/cm3UJrabZH?file=css

Describe your issue

This very specific input (I think the &:not([some-attribute]) plays a big part here)

.check {
  &:not([some-attribute]) {
    &.but-deeply-nested {
      .tailwind-value {
        @apply bg-black;
        color: red;
      }
    }
  }
}

ends up in the following output

tailwind 3.1.8 🟢

.check:not([some-attribute]).but-deeply-nested .tailwind-value {
  --tw-bg-opacity: 1;
  background-color: rgb(0 0 0 / var(--tw-bg-opacity));
  color: red;
}

tailwind 3.2.0+ 🔴 (the tailwind apply results in an incorrect interpretation of the selector it was in)

.check.but-deeply-nested.tailwind-value:not([some-attribute])  {
  --tw-bg-opacity: 1;
  background-color: rgb(0 0 0 / var(--tw-bg-opacity));
}

.check:not([some-attribute]).but-deeply-nested .tailwind-value {
  color: red;
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
RobinMalfaitcommented, Nov 3, 2022

@gynekolog yep! If you switch to the insiders build on Tailwind Play, then you can see the fix in action: https://play.tailwindcss.com/ex9MjTpmCU?file=css @Techn1x you’re welcome!

I’ll also make sure to do a release asap.

1reaction
RobinMalfaitcommented, Nov 3, 2022

Hey! Thank you for your bug report! Much appreciated! 🙏

This should be fixed by #9722, and will be available in the next release.

You can already try it by using the insiders build npm install tailwindcss@insiders.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pseudo-classes - CSS: Cascading Style Sheets | MDN
Represents an element with incorrect input, but only when the user has interacted with it. Linguistic pseudo-classes. These pseudo-classes ...
Read more >
Selectors Level 4 - W3C
Selectors are patterns that match against elements in a tree, and as such form one of several technologies that can be used to...
Read more >
Multiple CSS Pseudo Classes - Stack Overflow
There is no problem nesting pseudo class selectors as long as the rules applied match the particular element in the DOM-tree .
Read more >
An Ultimate Guide To CSS Pseudo Classes And Pseudo ...
There was no Smashing Magazine, Can I Use, CodePen or any of the other amazing tools at our disposal today. Having someone show...
Read more >
How the CSS :is, :where and :has Pseudo-class Selectors Work
You can also use selectors in JavaScript to locate DOM nodes: ... A single selector can contain any number of :is() pseudo-classes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found