1111#include " sass_functions.h"
1212
1313#include < typeinfo>
14+ #include < tuple>
1415
1516namespace Sass {
1617 using namespace std ;
@@ -220,7 +221,8 @@ namespace Sass {
220221
221222 void Parser::import_single_file (Import* imp, string import_path) {
222223
223- if (!unquote (import_path).substr (0 , 7 ).compare (" http://" ) ||
224+ if (imp->media_queries () ||
225+ !unquote (import_path).substr (0 , 7 ).compare (" http://" ) ||
224226 !unquote (import_path).substr (0 , 8 ).compare (" https://" ) ||
225227 !unquote (import_path).substr (0 , 2 ).compare (" //" ))
226228 {
@@ -282,14 +284,16 @@ namespace Sass {
282284 {
283285 lex< kwd_import >();
284286 Import* imp = new (ctx.mem ) Import (pstate);
287+ vector<pair<string,Function_Call*>> to_import;
285288 bool first = true ;
286289 do {
287290 while (lex< block_comment >());
288291 if (lex< quoted_string >()) {
289292 if (!do_import (lexed, imp, ctx.c_importers , true ))
290293 {
291294 // push single file import
292- import_single_file (imp, lexed);
295+ // import_single_file(imp, lexed);
296+ to_import.push_back (pair<string,Function_Call*>(string (lexed), 0 ));
293297 }
294298 }
295299 else if (lex< uri_prefix >()) {
@@ -311,14 +315,29 @@ namespace Sass {
311315 error (" malformed URL" , pstate);
312316 }
313317 if (!lex< exactly<' )' > >()) error (" URI is missing ')'" , pstate);
314- imp->urls ().push_back (result);
318+ // imp->urls().push_back(result);
319+ to_import.push_back (pair<string,Function_Call*>(" " , result));
315320 }
316321 else {
317322 if (first) error (" @import directive requires a url or quoted path" , pstate);
318323 else error (" expecting another url or quoted path in @import list" , pstate);
319324 }
320325 first = false ;
321326 } while (lex_css< exactly<' ,' > >());
327+
328+ if (!peek_css<alternatives<exactly<' ;' >,end_of_file>>()) {
329+ List* media_queries = parse_media_queries ();
330+ imp->media_queries (media_queries);
331+ }
332+
333+ for (auto location : to_import) {
334+ if (location.second ) {
335+ imp->urls ().push_back (location.second );
336+ } else {
337+ import_single_file (imp, location.first );
338+ }
339+ }
340+
322341 return imp;
323342 }
324343
0 commit comments