Skip to content

Commit fa8813d

Browse files
committed
Merge pull request #1483 from mgreter/bugfix/compound-selector-merging
Implement `Compound_Selector` merging in `append` function
2 parents 26909a8 + a0391cd commit fa8813d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/ast.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,26 @@ namespace Sass {
821821
if (h && h->length()) {
822822
if (last()->combinator() != ANCESTOR_OF && c != ANCESTOR_OF) {
823823
error("Invalid parent selector", pstate_);
824+
} else if (last()->head_ && last()->head_->length()) {
825+
Compound_Selector* rh = last()->head();
826+
size_t i = 0, L = h->length();
827+
if (Type_Selector* ts = dynamic_cast<Type_Selector*>(h->first())) {
828+
if (Selector_Qualifier* sq = dynamic_cast<Selector_Qualifier*>(rh->last())) {
829+
Selector_Qualifier* sqs = new Selector_Qualifier(*sq);
830+
sqs->name(sqs->name() + (*h)[0]->name());
831+
(*rh)[rh->length()-1] = sqs;
832+
for (i = 1; i < L; ++i) *rh << (*h)[i];
833+
} else if (Type_Selector* ts = dynamic_cast<Type_Selector*>(rh->last())) {
834+
Type_Selector* tss = new Type_Selector(*ts);
835+
tss->name(tss->name() + (*h)[0]->name());
836+
(*rh)[rh->length()-1] = tss;
837+
for (i = 1; i < L; ++i) *rh << (*h)[i];
838+
} else {
839+
*last()->head_ += h;
840+
}
841+
} else {
842+
*last()->head_ += h;
843+
}
824844
} else {
825845
*last()->head_ += h;
826846
}

0 commit comments

Comments
 (0)