From 41ce53d9105ab6d0e9e9781522166700c9408461 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Fri, 2 Sep 2016 03:50:46 +0200 Subject: [PATCH] Fix output with unhoistables and make comments hoistable Fixes https://github.com/sass/libsass/issues/2158 --- src/ast.hpp | 1 + src/output.cpp | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ast.hpp b/src/ast.hpp index 13543f0ccf..0ae676dab2 100644 --- a/src/ast.hpp +++ b/src/ast.hpp @@ -683,6 +683,7 @@ namespace Sass { { statement_type(COMMENT); } virtual bool is_invisible() const { return /* is_important() == */ false; } + bool is_hoistable() { return true; } ATTACH_OPERATIONS() }; diff --git a/src/output.cpp b/src/output.cpp index a369746390..1b5a410068 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -240,19 +240,16 @@ namespace Sass { append_token("@supports", f); append_mandatory_space(); c->perform(this); - append_scope_opener(); if (b->has_non_hoistable()) { - // JMA - hoisted, output the non-hoistable in a nested block, followed by the hoistable append_scope_opener(); - + // JMA - hoisted, output the non-hoistable in a nested block, followed by the hoistable for (size_t i = 0, L = b->length(); i < L; ++i) { Statement* stm = (*b)[i]; if (!stm->is_hoistable()) { stm->perform(this); } } - append_scope_closer(); for (size_t i = 0, L = b->length(); i < L; ++i) { @@ -263,18 +260,18 @@ namespace Sass { } } else { + append_scope_opener(); // JMA - not hoisted, just output in order for (size_t i = 0, L = b->length(); i < L; ++i) { Statement* stm = (*b)[i]; stm->perform(this); if (i < L - 1) append_special_linefeed(); } + append_scope_closer(); } if (output_style() == NESTED) indentation -= f->tabs(); - append_scope_closer(); - } void Output::operator()(Media_Block* m)