Skip to content

Commit

Permalink
Merge pull request #1955 from xzyfer/fix/issue-1644
Browse files Browse the repository at this point in the history
Fix error not being thrown when & is used without a parent selector
  • Loading branch information
xzyfer committed Mar 17, 2016
2 parents f5b02c9 + 32c921a commit 213339a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ namespace Sass {
Selector_List* sel = dynamic_cast<Selector_List*>(ex);
if (sel == 0) throw std::runtime_error("Expanded null selector");

if (sel->length() == 0 || sel->has_parent_ref()) {
bool has_parent_selector = false;
for (size_t i = 0, L = selector_stack.size(); i < L && !has_parent_selector; i++) {
Selector_List* ll = selector_stack.at(i);
has_parent_selector = ll != 0 && ll->length() > 0;
}
if (!has_parent_selector) {
error("Base-level rules cannot contain the parent-selector-referencing character '&'.", sel->pstate(), backtrace());
}
}

selector_stack.push_back(sel);
Env* env = 0;
if (block_stack.back()->is_root()) {
Expand Down

0 comments on commit 213339a

Please sign in to comment.