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.

Support "selector&"

See original GitHub issue
.bar {
    foo& { 
        color: baz;
    }
}

Causes an error. (See: http://codepen.io/anon/pen/GIufH)

This is surprising (since .bar { foo & { ... } } works like a charm), and this error prevents several useful selector prefixing patterns.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:28
  • Comments:32 (7 by maintainers)

github_iconTop GitHub Comments

32reactions
lolmauscommented, Sep 10, 2014

It’s not a hack, it’s the way meant to be done.

…is not the desired CSS.

In this case, use the @at-root directive:

.bar {
    @at-root foo#{&} { 
        color: baz;
    }
}

Demo: http://sassmeister.com/gist/8bd827341243d66e61d5

13reactions
lolmauscommented, Sep 12, 2014

@nex3, thank you for clarifications.

But don’t you agree that

.bar {
  @at-root #{selector-append(foo, &)} { color: baz; }
}

Is way too much typing, compared to LESS’

.bar {
 foo& { color: baz; }
}

There should be a simple way to write that. In projects using this convention, people type it like 100 times every day.

Read more comments on GitHub >

github_iconTop Results From Across the Web

supports selector() - CSS-Tricks
I didn't realize the support for @supports determining selector support was so good! I usually think of @supports as a way to test...
Read more >
supports - CSS: Cascading Style Sheets - MDN Web Docs
The @supports CSS at-rule lets you specify CSS declarations that depend on a browser's support for CSS features. Using this at-rule is ...
Read more >
AT&T Device Support – Select a Phone, Tablet, or Device Brand
Get smartphone, tablet & mobile device support from AT&T. Start by selecting the brand of your phone, tablet, or mobile device from this...
Read more >
CSS at-rule: @supports : selector() - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
CSS { In Real Life } | Detecting CSS Selector Support
Detecting selector support. CSS has given us some pretty cool selectors recently in the form of pseudo-elements and pseudo-classes. For example, ...
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