The parent selector is always a reference to the entire allowed selector from the previous nesting level. There is no concept of “parent” or “grandmother,” especially when clutching selectors or using a parental selector at the end mix water.
: , .
Sass 3.4, , & . ( ..).
, :
@function selector-slice($sel, $start: 1, $end: -1) {
$collector: ();
@each $s in $sel {
$_s: if($start > 0, $start, length($s) + $start + 1);
$_e: if($end > 0, $end, length($s) + $end + 1);
$c: ();
@for $i from $_s through $_e {
$c: append($c, nth($s, $i));
}
@if not index($collector, $c) {
$collector: append($collector, $c);
}
}
@return $collector;
}
.one-a, .one-b {
two {
three {
color: red;
&:before {
@at-root
color: green;
}
}
}
}
}
.class {
label {
color:
@at-root
.disabled & {
color:
}
}
}
}
:
.one-a two three, .one-b two three {
color: red;
}
two three:before {
color: green;
}
.class label {
color: #fff;
}
.disabled label {
color: #333;
}
, , .
.one-a, .one-b {
two {
three {
color: red;
&:before {
@at-root #{selector-slice(&, 3, 2)} {
color: green;
}
}
}
}
}
:
.one-a two three, .one-b two three {
color: red;
}
three:before two {
color: green;
}
: Sass (/ ..)
selector-replace , , , .
.class {
label {
color:
@at-root
color:
}
}
}
:
.class label {
color: #fff;
}
.disabled label {
color: #333;
}