Skip to content

Commit

Permalink
Fix extend issue being stuck in endless loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Oct 18, 2019
1 parent 4da7c4b commit 1ec3876
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/eval_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ namespace Sass {
SelectorList* Eval::operator()(ComplexSelector* s)
{
bool implicit_parent = !exp.old_at_root_without_rule;
if (is_in_selector_schema) exp.pushToSelectorStack({});
if (is_in_selector_schema) exp.pushNullSelector();
SelectorListObj other = s->resolve_parent_refs(
exp.getSelectorStack(), traces, implicit_parent);
if (is_in_selector_schema) exp.popFromSelectorStack();
exp.getOriginalStack(), traces, implicit_parent);
if (is_in_selector_schema) exp.popNullSelector();

for (size_t i = 0; i < other->length(); i++) {
ComplexSelectorObj sel = other->at(i);
Expand Down
29 changes: 23 additions & 6 deletions src/expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ namespace Sass {
return 0;
}

void Expand::pushNullSelector()
{
pushToSelectorStack({});
pushToOriginalStack({});
}

void Expand::popNullSelector()
{
popFromOriginalStack();
popFromSelectorStack();
}

SelectorStack Expand::getOriginalStack()
{
return originalStack;
}

SelectorStack Expand::getSelectorStack()
{
return selector_stack;
Expand Down Expand Up @@ -153,15 +170,15 @@ namespace Sass {
Block* bb = operator()(r->block());
Keyframe_Rule_Obj k = SASS_MEMORY_NEW(Keyframe_Rule, r->pstate(), bb);
if (r->schema()) {
pushToSelectorStack({});
pushNullSelector();
k->name(eval(r->schema()));
popFromSelectorStack();
popNullSelector();
}
else if (r->selector()) {
if (SelectorListObj s = r->selector()) {
pushToSelectorStack({});
pushNullSelector();
k->name(eval(s));
popFromSelectorStack();
popNullSelector();
}
}

Expand Down Expand Up @@ -288,10 +305,10 @@ namespace Sass {
Block* ab = a->block();
SelectorList* as = a->selector();
Expression* av = a->value();
pushToSelectorStack({});
pushNullSelector();
if (av) av = av->perform(&eval);
if (as) as = eval(as);
popFromSelectorStack();
popNullSelector();
Block* bb = ab ? operator()(ab) : NULL;
Directive* aa = SASS_MEMORY_NEW(Directive,
a->pstate(),
Expand Down
3 changes: 3 additions & 0 deletions src/expand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ namespace Sass {
SelectorListObj& selector();
SelectorListObj& original();
SelectorListObj popFromSelectorStack();
SelectorStack getOriginalStack();
SelectorStack getSelectorStack();
void pushNullSelector();
void popNullSelector();
void pushToSelectorStack(SelectorListObj selector);

SelectorListObj popFromOriginalStack();
Expand Down
4 changes: 2 additions & 2 deletions src/extender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ namespace Sass {
std::unordered_map<
SimpleSelectorObj,
size_t,
ObjHash,
ObjEquality
ObjPtrHash,
ObjPtrEquality
> sourceSpecificity;

// ##########################################################################
Expand Down

0 comments on commit 1ec3876

Please sign in to comment.