Reputation: 5063
I have this LESS:
custom-component {
.random-class {
.decorator-class& wrapper {
...
}
}
that yields
.decorator-classcustom-component .random-class wrapper {
...
}
which outputs gibberish because there is no such class .decorator-classcustom-component
. This happens because the uppermost parent selector is an HTML element tag and not a class or other selector type.
Is there a way to get the characters before the ampersand (.decorator-class
) to concatenate on the right side of the uppermost parent selector? Like this:
custom-component.decorator-class .random-class wrapper
?
Note that attempting,
custom-component {
.random-class {
&.decorator-class wrapper {
// ^ ampersand at the beginning of selector
...
}
}
would yield,
custom-component .random-class.decorator-class wrapper
Upvotes: 0
Views: 1399
Reputation: 7673
I find it really useful to translate CSS selectors to English for debugging in situations like this. Your desired selector custom-component.decorator-class .random-class wrapper
translates to:
Select
wrapper
elements inside an element with a classrandom-class
, inside acustom-component
element with the class.decorator-class
.
If that's what you mean, then you need something like this:
custom-component {
&.decorator-class {
.random-class wrapper {
...
}
}
Upvotes: 1