Skip to content

Commit

Permalink
Improve at-root handling with mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Oct 19, 2015
1 parent aa4dbbf commit 6771801
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,10 @@ namespace Sass {
Compound_Selector* h = 0,
Complex_Selector* t = 0,
String* r = 0)
: Selector(pstate), combinator_(c), head_(h), tail_(t), reference_(r)
: Selector(pstate),
combinator_(c),
head_(h), tail_(t),
reference_(r)
{
if ((h && h->has_reference()) || (t && t->has_reference())) has_reference(true);
if ((h && h->has_placeholder()) || (t && t->has_placeholder())) has_placeholder(true);
Expand Down
3 changes: 2 additions & 1 deletion src/debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " " << root_block->tabs();
std::cerr << std::endl;
if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); }
debug_ast(root_block->expression(), ind + ":", env);
debug_ast(root_block->block(), ind + " ", env);
} else if (dynamic_cast<Selector_List*>(node)) {
Selector_List* selector = dynamic_cast<Selector_List*>(node);
std::cerr << ind << "Selector_List " << selector;
Expand Down
10 changes: 9 additions & 1 deletion src/expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace Sass {
r->pstate(),
sel,
blk);
// rr->selector()->is_at_root(true);
selector_stack.pop_back();
rr->tabs(r->tabs());

Expand Down Expand Up @@ -625,11 +626,18 @@ namespace Sass {
Env* env = environment();
// convert @content directives into mixin calls to the underlying thunk
if (!env->has("@content[m]")) return 0;
if (block_stack.back()->is_root()) {
selector_stack.push_back(0);
}
Mixin_Call* call = SASS_MEMORY_NEW(ctx.mem, Mixin_Call,
c->pstate(),
"@content",
SASS_MEMORY_NEW(ctx.mem, Arguments, c->pstate()));
return call->perform(this);
Statement* stm = call->perform(this);
if (block_stack.back()->is_root()) {
selector_stack.pop_back();
}
return stm;
}

// produce an error if something is not implemented
Expand Down

0 comments on commit 6771801

Please sign in to comment.