Skip to content

Commit 09e41e6

Browse files
committed
Fix nesting check for at-root
1 parent 373859c commit 09e41e6

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/check_nesting.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ namespace Sass {
4040
}
4141

4242
At_Root_Block_Ptr ar = Cast<At_Root_Block>(parent);
43-
Statement_Ptr ret = this->visit_children(ar->block());
43+
Block_Ptr ret = ar->block();
44+
45+
for (auto n : ret->elements()) {
46+
n->perform(this);
47+
}
4448

4549
this->parent = old_parent;
4650
this->parents = old_parents;

src/parser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ namespace Sass {
295295
else if (lex< re_prefixed_directive >(true)) { block->append(parse_prefixed_directive()); }
296296
else if (lex< at_keyword >(true)) { block->append(parse_directive()); }
297297

298-
else if (is_root /* && block->is_root() */) {
298+
else if (is_root && stack.back() != Scope::AtRoot /* && block->is_root() */) {
299299
lex< css_whitespace >();
300300
if (position >= end) return true;
301301
css_error("Invalid CSS", " after ", ": expected 1 selector or at-rule, was ");
@@ -2479,6 +2479,7 @@ namespace Sass {
24792479

24802480
At_Root_Block_Obj Parser::parse_at_root_block()
24812481
{
2482+
stack.push_back(Scope::AtRoot);
24822483
ParserState at_source_position = pstate;
24832484
Block_Obj body = 0;
24842485
At_Root_Query_Obj expr;
@@ -2497,6 +2498,7 @@ namespace Sass {
24972498
}
24982499
At_Root_Block_Obj at_root = SASS_MEMORY_NEW(At_Root_Block, at_source_position, body);
24992500
if (!expr.isNull()) at_root->expression(expr);
2501+
stack.pop_back();
25002502
return at_root;
25012503
}
25022504

src/parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Sass {
3333
class Parser : public ParserState {
3434
public:
3535

36-
enum Scope { Root, Mixin, Function, Media, Control, Properties, Rules };
36+
enum Scope { Root, Mixin, Function, Media, Control, Properties, Rules, AtRoot };
3737

3838
Context& ctx;
3939
std::vector<Block_Obj> block_stack;

0 commit comments

Comments
 (0)