[JIT] Class based variant bug when chaining
See original GitHub issueWhat version of Tailwind CSS are you using?
v2.2.7
What build tool (or framework if it abstracts the build tool) are you using?
postcss v8.3.6
What version of Node.js are you using?
v14.15.5
What browser are you using?
chrome
What operating system are you using?
macOS
Reproduction repository
https://github.com/minimit/twbug-class-variant-chain
Describe your issue
When using custom variants with classes instead of pseudo selectors, and chaining multiple variants, the output is wrong.
This is the code of the addVariant
.
addVariant('class', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`class${separator}${className}`)}.class`
})
})
This is the code of the apply or html class.
.test-class {
@apply sm:class:hidden;
}
This is the output.
@media (min-width: 640px) {
{
display: none
}
}
This is the desired output.
@media (min-width: 640px) {
.test-class.class {
display: none
}
}
Seems also html class does the same.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
As a JS Developer, This Is What Keeps Me Up at Night - Toptal
A class constructor creates an instance of the class. A constructor in JavaScript is just a plain old function that returns an object....
Read more >Override Tailwind CSS @apply directive on chained selectors
1 Answer 1 · 2. I'm not sure setting ! · can you set the dynamic class to solve this problem without !important...
Read more >Exploit writing tutorial part 10 : Chaining DEP with ROP
In the previous tutorials, I have explained the basics of stack based overflows and how they can lead to arbitrary code execution.
Read more >GATK - Broad Institute
A genomic analysis toolkit focused on variant discovery. The GATK is the industry standard for identifying SNPs and indels in germline DNA and...
Read more >Functions & Directives - Tailwind CSS
@tailwind base; /** * This injects Tailwind's component classes and any component ... focus, * responsive, dark mode, and other variants of each...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey! Thank you for your bug report! Much appreciated! 🙏
I’ve been debugging on what’s going on here exactly. The issue is not that custom variants like that don’t work, the problem currently is what the result of the modified selector is.
I will make a PR to fix this, however there is an easier solution you can already apply for your use case:
Essentially moving the
.class
in front. The reason why this works and the others don’t is because of an internal assumption where we update the last class of a selector, however, when you eventually have.hidden.class
the last class isclass
, which should not be updated.I’ll leave this open for now and will link my PR once it is ready, but in the meantime my small solution above should fix your issue for now.
Thanks works like a charm you delivered 👍