Skip to content

Commit d7a7a58

Browse files
committed
Add special check nesting handling for @else
We treat `@else` as a block which breaks the check nesting algorithm ported over from Ruby Sass. With change the intermediate `Block` to container `@else` children is invisible. This better emulates the the Ruby Sass algorithm. Fixes #2569
1 parent 051de01 commit d7a7a58

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/check_nesting.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ namespace Sass {
103103
return n;
104104
}
105105

106+
Statement_Ptr CheckNesting::operator()(If_Ptr i)
107+
{
108+
this->visit_children(i);
109+
110+
if (Block_Ptr b = Cast<Block>(i->alternative())) {
111+
for (auto n : i->alternative()->elements()) {
112+
n->perform(this);
113+
}
114+
}
115+
116+
return i;
117+
}
118+
106119
Statement_Ptr CheckNesting::fallback_impl(Statement_Ptr s)
107120
{
108121
Block_Ptr b1 = Cast<Block>(s);

src/check_nesting.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace Sass {
2222

2323
Statement_Ptr operator()(Block_Ptr);
2424
Statement_Ptr operator()(Definition_Ptr);
25+
Statement_Ptr operator()(If_Ptr);
2526

2627
template <typename U>
2728
Statement_Ptr fallback(U x) {

0 commit comments

Comments
 (0)