@@ -124,6 +124,82 @@ namespace Sass {
124124 }
125125 }
126126
127+ void Output_Nested::operator ()(Feature_Block* f)
128+ {
129+ Feature_Queries* q = f->feature_queries ();
130+ Block* b = f->block ();
131+
132+ // Filter out feature blocks that aren't printable (process its children though)
133+ if (!Util::isPrintable (f)) {
134+ for (size_t i = 0 , L = b->length (); i < L; ++i) {
135+ Statement* stm = (*b)[i];
136+ if (dynamic_cast <Has_Block*>(stm)) {
137+ stm->perform (this );
138+ }
139+ }
140+ return ;
141+ }
142+
143+ indent ();
144+ ctx->source_map .add_mapping (f);
145+ append_to_buffer (" @supports " );
146+ q->perform (this );
147+ append_to_buffer (" {\n " );
148+
149+ Selector* e = f->selector ();
150+ if (e && b->has_non_hoistable ()) {
151+ // JMA - hoisted, output the non-hoistable in a nested block, followed by the hoistable
152+ ++indentation;
153+ indent ();
154+ e->perform (this );
155+ append_to_buffer (" {\n " );
156+
157+ ++indentation;
158+ for (size_t i = 0 , L = b->length (); i < L; ++i) {
159+ Statement* stm = (*b)[i];
160+ if (!stm->is_hoistable ()) {
161+ if (!stm->block ()) indent ();
162+ stm->perform (this );
163+ append_to_buffer (" \n " );
164+ }
165+ }
166+ --indentation;
167+
168+ buffer.erase (buffer.length ()-1 );
169+ if (ctx) ctx->source_map .remove_line ();
170+ append_to_buffer (" }\n " );
171+ --indentation;
172+
173+ ++indentation;
174+ ++indentation;
175+ for (size_t i = 0 , L = b->length (); i < L; ++i) {
176+ Statement* stm = (*b)[i];
177+ if (stm->is_hoistable ()) {
178+ stm->perform (this );
179+ }
180+ }
181+ --indentation;
182+ --indentation;
183+ }
184+ else {
185+ // JMA - not hoisted, just output in order
186+ ++indentation;
187+ for (size_t i = 0 , L = b->length (); i < L; ++i) {
188+ Statement* stm = (*b)[i];
189+ if (!stm->is_hoistable ()) {
190+ if (!stm->block ()) indent ();
191+ }
192+ stm->perform (this );
193+ append_to_buffer (" \n " );
194+ }
195+ --indentation;
196+ }
197+
198+ buffer.erase (buffer.length ()-1 );
199+ if (ctx) ctx->source_map .remove_line ();
200+ append_to_buffer (" }\n " );
201+ }
202+
127203 void Output_Nested::operator ()(Media_Block* m)
128204 {
129205 List* q = m->media_queries ();
@@ -139,7 +215,7 @@ namespace Sass {
139215 }
140216 return ;
141217 }
142-
218+
143219 indent ();
144220 ctx->source_map .add_mapping (m);
145221 append_to_buffer (" @media " );
@@ -153,7 +229,7 @@ namespace Sass {
153229 indent ();
154230 e->perform (this );
155231 append_to_buffer (" {\n " );
156-
232+
157233 ++indentation;
158234 for (size_t i = 0 , L = b->length (); i < L; ++i) {
159235 Statement* stm = (*b)[i];
@@ -164,12 +240,12 @@ namespace Sass {
164240 }
165241 }
166242 --indentation;
167-
243+
168244 buffer.erase (buffer.length ()-1 );
169245 if (ctx) ctx->source_map .remove_line ();
170246 append_to_buffer (" }\n " );
171247 --indentation;
172-
248+
173249 ++indentation;
174250 ++indentation;
175251 for (size_t i = 0 , L = b->length (); i < L; ++i) {
@@ -194,7 +270,7 @@ namespace Sass {
194270 }
195271 --indentation;
196272 }
197-
273+
198274 buffer.erase (buffer.length ()-1 );
199275 if (ctx) ctx->source_map .remove_line ();
200276 append_to_buffer (" }\n " );
0 commit comments