lib/css_parser/parser.rb in css_parser-1.3.5 vs lib/css_parser/parser.rb in css_parser-1.3.6

- old
+ new

@@ -117,29 +117,31 @@ if options[:base_uri] and @options[:absolute_paths] block = CssParser.convert_uris(block, options[:base_uri]) end # Load @imported CSS - block.scan(RE_AT_IMPORT_RULE).each do |import_rule| - media_types = [] - if media_string = import_rule[-1] - media_string.split(/[,]/).each do |t| - media_types << CssParser.sanitize_media_query(t) unless t.empty? + if @options[:import] + block.scan(RE_AT_IMPORT_RULE).each do |import_rule| + media_types = [] + if media_string = import_rule[-1] + media_string.split(/[,]/).each do |t| + media_types << CssParser.sanitize_media_query(t) unless t.empty? + end + else + media_types = [:all] end - else - media_types = [:all] - end - next unless options[:only_media_types].include?(:all) or media_types.length < 1 or (media_types & options[:only_media_types]).length > 0 + next unless options[:only_media_types].include?(:all) or media_types.length < 1 or (media_types & options[:only_media_types]).length > 0 - import_path = import_rule[0].to_s.gsub(/['"]*/, '').strip + import_path = import_rule[0].to_s.gsub(/['"]*/, '').strip - if options[:base_uri] - import_uri = Addressable::URI.parse(options[:base_uri].to_s) + Addressable::URI.parse(import_path) - load_uri!(import_uri, options[:base_uri], media_types) - elsif options[:base_dir] - load_file!(import_path, options[:base_dir], media_types) + if options[:base_uri] + import_uri = Addressable::URI.parse(options[:base_uri].to_s) + Addressable::URI.parse(import_path) + load_uri!(import_uri, options[:base_uri], media_types) + elsif options[:base_dir] + load_file!(import_path, options[:base_dir], media_types) + end end end # Remove @import declarations block.gsub!(RE_AT_IMPORT_RULE, '') @@ -321,10 +323,10 @@ if token =~ /\}/ and not in_string block_depth = block_depth - 1 # reset the current media query scope if in_media_block - current_media_queries = [] + current_media_queries = [:all] in_media_block = false end else if token =~ /\{/ and not in_string current_selectors.gsub!(/^[\s]*/, '')