Adding a tag selector with & generates bad CSS
See original GitHub issueLooks like the parser just does a blind concatenation for nested selectors. Sometimes it should be more intelligent. For example:
.foo {
.bar {
&select {
// stuff
}
}
}
generates:
.foo .barselect {
// stuff
}
expected:
.foo select.bar {
// stuff
}
My current workaround:
.foo {
.bar {
}
select {
@extend .bar;
}
}
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Is element-specific CSS selector bad? - html - Stack Overflow
CSS selectors are read right to left. So p.error has one additional step to .error . This may result in a smaller set...
Read more >You Need to Stop Targeting Tags in CSS | frontstuff
You're using the existing DOM structure, you're unleashing the power of CSS operators, you're not adding unnecessary classes, and it works. But ...
Read more >Specificity - CSS: Cascading Style Sheets - MDN Web Docs
It enables making CSS selectors very specific in what element is targeted without any increase to specificity. In creating third-party CSS to be ......
Read more >Advanced CSS Selectors you never knew about - Medium
You can do it for any element (div, span, img, etc…), and any common attribute (id, name, value, etc…).
Read more >Creating actions using CSS selectors - PostHog
Under the hood the toolbar generates a CSS selector matching the UI element. The toolbar is quite clever, but sometimes automatically generated selectors...
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 FreeTop 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
Top GitHub Comments
@SilentSpammer Support for
selector&
is being tracked in https://github.com/sass/sass/issues/1425. That said, it still won’t satisfy your use-case, because&
will always inject the full parent selector, so you’ll getselect.foo .bar
. Here’s how I’d handle that:The
selector-unify()
function returns a selector that matches only elements matched by both its arguments, which looks like what you’re trying to express here.Fair enough. Feel free to close the bug. At least now there’s a search result on GitHub that can help people who experience this issue.