Skip to content

Commit 2874410

Browse files
committed
Improve at-root handling with mixins
1 parent aa4dbbf commit 2874410

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/ast.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,10 @@ namespace Sass {
21172117
Compound_Selector* h = 0,
21182118
Complex_Selector* t = 0,
21192119
String* r = 0)
2120-
: Selector(pstate), combinator_(c), head_(h), tail_(t), reference_(r)
2120+
: Selector(pstate),
2121+
combinator_(c),
2122+
head_(h), tail_(t),
2123+
reference_(r)
21212124
{
21222125
if ((h && h->has_reference()) || (t && t->has_reference())) has_reference(true);
21232126
if ((h && h->has_placeholder()) || (t && t->has_placeholder())) has_placeholder(true);

src/debugger.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
7171
std::cerr << " (" << pstate_source_position(node) << ")";
7272
std::cerr << " " << root_block->tabs();
7373
std::cerr << std::endl;
74-
if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); }
74+
debug_ast(root_block->expression(), ind + ":", env);
75+
debug_ast(root_block->block(), ind + " ", env);
7576
} else if (dynamic_cast<Selector_List*>(node)) {
7677
Selector_List* selector = dynamic_cast<Selector_List*>(node);
7778
std::cerr << ind << "Selector_List " << selector;

src/expand.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,18 @@ namespace Sass {
625625
Env* env = environment();
626626
// convert @content directives into mixin calls to the underlying thunk
627627
if (!env->has("@content[m]")) return 0;
628+
if (block_stack.back()->is_root()) {
629+
selector_stack.push_back(0);
630+
}
628631
Mixin_Call* call = SASS_MEMORY_NEW(ctx.mem, Mixin_Call,
629632
c->pstate(),
630633
"@content",
631634
SASS_MEMORY_NEW(ctx.mem, Arguments, c->pstate()));
632-
return call->perform(this);
635+
Statement* stm = call->perform(this);
636+
if (block_stack.back()->is_root()) {
637+
selector_stack.pop_back();
638+
}
639+
return stm;
633640
}
634641

635642
// produce an error if something is not implemented

0 commit comments

Comments
 (0)