-
Notifications
You must be signed in to change notification settings - Fork 3.4k
An empty variable used as a selector for a scope works, but is it an intentional language feature? #2911
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
Comments
Use |
Can you give an example, because I've already tried that. It outputs the & character in the generated CSS.
or
generates
|
& {
.red {
color: red;
}
} (Not counting that for this snippet you don't need any extra selector since Or do you mean that you just need some variable that can either produce an identifier or an empty value (i.e. with "scope" you mean just "HTML scope")? Then yes, |
The variable may be poorly named, basically my original comment is a working example of exactly what I'm trying to achieve. A LESS variable adds an optional CSS class in front of everything, or no class if the variable is empty. I was just asking if |
@Giwayume I'd say there's at least some risk that You could also do something like: .scope(@sel) {
@{sel} {
.selectors();
}
}
.scope() {
.selectors();
}
.selectors() {
.red {
color: red;
}
}
.scope(); |
So there's no official way to just make a variable output nothing? Like an empty string? |
|
Does that mean this is by design:
Or is it any better or worse than just leaving it out?
|
Yet again, there's no plans to change |
Closing as expected behaviour. |
I wanted a variable that optionally adds an extra CSS class to scope some selectors, and this works:
This:
Generates:
And this:
Generates:
I'm not confident that the first example with
@scope-selector:;
is an intentional language feature, though. Can someone confirm this?The text was updated successfully, but these errors were encountered: