From 28744103962ec598f38a43fc7bd2e39cd88e5f8f Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Mon, 19 Oct 2015 05:47:43 +0200 Subject: [PATCH] Improve at-root handling with mixins --- src/ast.hpp | 5 ++++- src/debugger.hpp | 3 ++- src/expand.cpp | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ast.hpp b/src/ast.hpp index c89688cdf2..7686b7d641 100644 --- a/src/ast.hpp +++ b/src/ast.hpp @@ -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); diff --git a/src/debugger.hpp b/src/debugger.hpp index 02f6aecfa3..76e4049c57 100644 --- a/src/debugger.hpp +++ b/src/debugger.hpp @@ -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(node)) { Selector_List* selector = dynamic_cast(node); std::cerr << ind << "Selector_List " << selector; diff --git a/src/expand.cpp b/src/expand.cpp index a485462db5..7673257247 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -625,11 +625,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