Skip to content

Commit

Permalink
Fix regression with parentize of wrapped selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Feb 22, 2016
1 parent 2acba9d commit a9c4215
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,38 @@ namespace Sass {
return ss;
}

Compound_Selector* Compound_Selector::parentize(Selector_List* parents, Context& ctx)
{
Compound_Selector* cpy = SASS_MEMORY_NEW(ctx.mem, Compound_Selector, this->pstate());
for (Simple_Selector* sel : this->elements()) {
if (Wrapped_Selector* ws = dynamic_cast<Wrapped_Selector*>(sel)) {
if (Selector_List* sl = dynamic_cast<Selector_List*>(ws->selector())) {
Selector_List* prl = sl->parentize(parents, ctx);
if (sl->length() > 1) {
*cpy << SASS_MEMORY_NEW(ctx.mem,
Wrapped_Selector,
ws->pstate(),
ws->name(),
prl);
} else {
for (Complex_Selector* prs : *prl) {
*cpy << SASS_MEMORY_NEW(ctx.mem,
Wrapped_Selector,
ws->pstate(),
ws->name(),
prs);
}
}
} else {
*cpy << sel;
}
} else {
*cpy << sel;
}
}
return cpy;
}

Selector_List* Complex_Selector::parentize(Selector_List* parents, Context& ctx)
{

Expand Down Expand Up @@ -1006,7 +1038,7 @@ namespace Sass {
throw Exception::InvalidParent(parent, ss);
}
ss->tail(tail ? tail->clone(ctx) : 0);
Compound_Selector* h = head_->clone(ctx);
Compound_Selector* h = head_->parentize(parents, ctx);
if (h->length()) h->erase(h->begin());
ss->head(h->length() ? h : 0);
// \/ IMO ruby sass bug \/
Expand Down
1 change: 1 addition & 0 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,6 +2219,7 @@ namespace Sass {
}

Complex_Selector* to_complex(Memory_Manager& mem);
Compound_Selector* parentize(Selector_List* parents, Context& ctx);
Compound_Selector* unify_with(Compound_Selector* rhs, Context& ctx);
// virtual Selector_Placeholder* find_placeholder();
virtual bool has_parent_ref();
Expand Down

0 comments on commit a9c4215

Please sign in to comment.