@at-root with #{&} inside a comma-separated selector generates wrong code
See original GitHub issueTested versions: v3.3.6 via node-sass (sorry, I can’t run/test it against the ruby implementation directly)
Given the following input:
.class-a {
.class-b,
.class-c {
color: yellow;
@at-root .something-at-root#{&} {
color: pink;
}
}
}
You’ll get the following output:
.class-a .class-b,
.class-a .class-c {
color: yellow;
}
.something-at-root.class-a .class-b,
.class-a .class-c {
color: pink;
}
The problem here is that #{&}
, which I used here in this example to prepend some selector (.something-at-root
) right at the beginning, which causes the compiler to generate wrong output.
I’d expect the following output for the second block:
.class-a .class-b,
.class-a .class-c {
color: yellow;
}
.something-at-root.class-a .class-b,
.something-at-root.class-a .class-c {
color: pink;
}
Clearly one could argue that I’ve abused #{}
and &
here though I couldn’t find another way to achieve the same result (apart from the potential bug). I’ve just expected that the compiler would treat string interpolation with the same rules as the rest.
To me it looks like the entire string is just pasted into its destination without honoring the ,
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
@richgcook See docs for
selector-append
. What you are looking for is selector_nest@chriseppstein This actually doesn’t work as it doesn’t create a space between the root selector and the child selector.
This compiles to