sass 3.4.25 → 3.5.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/README.md +1 -1
  4. data/Rakefile +13 -157
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/lib/sass.rb +3 -10
  9. data/lib/sass/cache_stores/filesystem.rb +1 -1
  10. data/lib/sass/css.rb +2 -3
  11. data/lib/sass/engine.rb +46 -32
  12. data/lib/sass/environment.rb +27 -6
  13. data/lib/sass/error.rb +5 -5
  14. data/lib/sass/exec/base.rb +3 -12
  15. data/lib/sass/features.rb +1 -0
  16. data/lib/sass/importers/filesystem.rb +2 -2
  17. data/lib/sass/plugin.rb +1 -1
  18. data/lib/sass/plugin/compiler.rb +21 -51
  19. data/lib/sass/plugin/configuration.rb +1 -1
  20. data/lib/sass/plugin/rack.rb +3 -3
  21. data/lib/sass/plugin/staleness_checker.rb +3 -3
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script.rb +3 -3
  24. data/lib/sass/script/functions.rb +238 -47
  25. data/lib/sass/script/lexer.rb +8 -6
  26. data/lib/sass/script/parser.rb +76 -75
  27. data/lib/sass/script/tree/funcall.rb +35 -30
  28. data/lib/sass/script/tree/list_literal.rb +23 -8
  29. data/lib/sass/script/tree/map_literal.rb +2 -2
  30. data/lib/sass/script/tree/node.rb +2 -10
  31. data/lib/sass/script/tree/operation.rb +16 -50
  32. data/lib/sass/script/value.rb +2 -0
  33. data/lib/sass/script/value/arg_list.rb +1 -1
  34. data/lib/sass/script/value/base.rb +20 -3
  35. data/lib/sass/script/value/callable.rb +25 -0
  36. data/lib/sass/script/value/color.rb +10 -10
  37. data/lib/sass/script/value/function.rb +19 -0
  38. data/lib/sass/script/value/helpers.rb +16 -7
  39. data/lib/sass/script/value/list.rb +33 -12
  40. data/lib/sass/script/value/map.rb +2 -2
  41. data/lib/sass/script/value/number.rb +3 -3
  42. data/lib/sass/script/value/string.rb +12 -5
  43. data/lib/sass/scss/parser.rb +101 -45
  44. data/lib/sass/scss/rx.rb +5 -11
  45. data/lib/sass/scss/static_parser.rb +0 -7
  46. data/lib/sass/selector.rb +4 -0
  47. data/lib/sass/selector/abstract_sequence.rb +5 -5
  48. data/lib/sass/selector/comma_sequence.rb +3 -15
  49. data/lib/sass/selector/pseudo.rb +4 -0
  50. data/lib/sass/selector/sequence.rb +30 -3
  51. data/lib/sass/selector/simple.rb +13 -7
  52. data/lib/sass/selector/simple_sequence.rb +1 -1
  53. data/lib/sass/shared.rb +3 -5
  54. data/lib/sass/source/map.rb +4 -4
  55. data/lib/sass/source/position.rb +4 -4
  56. data/lib/sass/stack.rb +21 -1
  57. data/lib/sass/tree/charset_node.rb +1 -1
  58. data/lib/sass/tree/comment_node.rb +1 -1
  59. data/lib/sass/tree/node.rb +3 -3
  60. data/lib/sass/tree/prop_node.rb +46 -54
  61. data/lib/sass/tree/rule_node.rb +7 -15
  62. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  63. data/lib/sass/tree/visitors/convert.rb +2 -3
  64. data/lib/sass/tree/visitors/cssize.rb +1 -10
  65. data/lib/sass/tree/visitors/deep_copy.rb +2 -2
  66. data/lib/sass/tree/visitors/perform.rb +23 -12
  67. data/lib/sass/tree/visitors/set_options.rb +1 -1
  68. data/lib/sass/tree/visitors/to_css.rb +46 -12
  69. data/lib/sass/util.rb +16 -321
  70. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  71. data/lib/sass/util/normalized_map.rb +1 -8
  72. data/lib/sass/version.rb +2 -2
  73. data/test/sass-spec.yml +1 -1
  74. data/test/sass/compiler_test.rb +4 -14
  75. data/test/sass/conversion_test.rb +113 -162
  76. data/test/sass/css2sass_test.rb +17 -19
  77. data/test/sass/css_variable_test.rb +176 -70
  78. data/test/sass/encoding_test.rb +2 -32
  79. data/test/sass/engine_test.rb +114 -65
  80. data/test/sass/extend_test.rb +37 -51
  81. data/test/sass/functions_test.rb +57 -15
  82. data/test/sass/importer_test.rb +2 -2
  83. data/test/sass/more_templates/more1.sass +10 -10
  84. data/test/sass/more_templates/more_import.sass +2 -2
  85. data/test/sass/plugin_test.rb +9 -12
  86. data/test/sass/script_conversion_test.rb +9 -0
  87. data/test/sass/script_test.rb +38 -48
  88. data/test/sass/scss/css_test.rb +5 -19
  89. data/test/sass/scss/scss_test.rb +58 -39
  90. data/test/sass/source_map_test.rb +26 -28
  91. data/test/sass/templates/_partial.sass +1 -1
  92. data/test/sass/templates/basic.sass +10 -10
  93. data/test/sass/templates/bork1.sass +1 -1
  94. data/test/sass/templates/bork5.sass +1 -1
  95. data/test/sass/templates/compact.sass +10 -10
  96. data/test/sass/templates/complex.sass +187 -187
  97. data/test/sass/templates/compressed.sass +10 -10
  98. data/test/sass/templates/expanded.sass +10 -10
  99. data/test/sass/templates/import.sass +2 -2
  100. data/test/sass/templates/importee.sass +3 -3
  101. data/test/sass/templates/mixins.sass +22 -22
  102. data/test/sass/templates/multiline.sass +4 -4
  103. data/test/sass/templates/nested.sass +13 -13
  104. data/test/sass/templates/parent_ref.sass +12 -12
  105. data/test/sass/templates/script.sass +70 -70
  106. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +1 -1
  107. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +2 -2
  108. data/test/sass/templates/subdir/subdir.sass +3 -3
  109. data/test/sass/templates/units.sass +10 -10
  110. data/test/sass/util/multibyte_string_scanner_test.rb +139 -149
  111. data/test/sass/util_test.rb +0 -36
  112. data/test/test_helper.rb +39 -0
  113. metadata +30 -57
  114. data/extra/sass-spec-ref.sh +0 -32
  115. data/lib/sass/deprecation.rb +0 -55
  116. data/lib/sass/script/css_variable_warning.rb +0 -52
  117. data/lib/sass/util/cross_platform_random.rb +0 -19
  118. data/lib/sass/util/ordered_hash.rb +0 -192
  119. data/test/sass/results/import_charset_1_8.css +0 -5
  120. data/test/sass/templates/import_charset_1_8.sass +0 -6
  121. data/vendor/listen/CHANGELOG.md +0 -1
  122. data/vendor/listen/CONTRIBUTING.md +0 -38
  123. data/vendor/listen/Gemfile +0 -20
  124. data/vendor/listen/Guardfile +0 -8
  125. data/vendor/listen/LICENSE +0 -20
  126. data/vendor/listen/README.md +0 -349
  127. data/vendor/listen/Rakefile +0 -5
  128. data/vendor/listen/Vagrantfile +0 -96
  129. data/vendor/listen/lib/listen.rb +0 -54
  130. data/vendor/listen/lib/listen/adapter.rb +0 -327
  131. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  132. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  133. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  134. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  135. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  136. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  137. data/vendor/listen/lib/listen/listener.rb +0 -323
  138. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  139. data/vendor/listen/lib/listen/version.rb +0 -3
  140. data/vendor/listen/listen.gemspec +0 -28
  141. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  142. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  143. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  144. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  145. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  146. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  147. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  148. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  149. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  150. data/vendor/listen/spec/listen_spec.rb +0 -67
  151. data/vendor/listen/spec/spec_helper.rb +0 -25
  152. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  153. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  154. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  155. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  156. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -14,13 +14,20 @@ module Sass::Script::Value
14
14
  # @return [Symbol]
15
15
  attr_reader :separator
16
16
 
17
+ # Whether the list is surrounded by square brackets.
18
+ #
19
+ # @return [Boolean]
20
+ attr_reader :bracketed
21
+
17
22
  # Creates a new list.
18
23
  #
19
24
  # @param value [Array<Value>] See \{#value}
20
25
  # @param separator [Symbol] See \{#separator}
21
- def initialize(value, separator)
26
+ # @param bracketed [Boolean] See \{#bracketed}
27
+ def initialize(value, separator: nil, bracketed: false)
22
28
  super(value)
23
29
  @separator = separator
30
+ @bracketed = bracketed
24
31
  end
25
32
 
26
33
  # @see Value#options=
@@ -42,15 +49,21 @@ module Sass::Script::Value
42
49
 
43
50
  # @see Value#to_s
44
51
  def to_s(opts = {})
45
- raise Sass::SyntaxError.new("() isn't a valid CSS value.") if value.empty?
46
- value.
52
+ if !bracketed && value.empty?
53
+ raise Sass::SyntaxError.new("#{inspect} isn't a valid CSS value.")
54
+ end
55
+
56
+ members = value.
47
57
  reject {|e| e.is_a?(Null) || e.is_a?(List) && e.value.empty?}.
48
- map {|e| e.to_s(opts)}.join(sep_str)
58
+ map {|e| e.to_s(opts)}
59
+
60
+ contents = members.join(sep_str)
61
+ bracketed ? "[#{contents}]" : contents
49
62
  end
50
63
 
51
64
  # @see Value#to_sass
52
65
  def to_sass(opts = {})
53
- return "()" if value.empty?
66
+ return bracketed ? "[]" : "()" if value.empty?
54
67
  members = value.map do |v|
55
68
  if element_needs_parens?(v)
56
69
  "(#{v.to_sass(opts)})"
@@ -58,19 +71,26 @@ module Sass::Script::Value
58
71
  v.to_sass(opts)
59
72
  end
60
73
  end
61
- return "(#{members.first},)" if members.length == 1 && separator == :comma
62
- members.join(sep_str(nil))
74
+
75
+ if separator == :comma && members.length == 1
76
+ return "#{bracketed ? '[' : '('}#{members.first},#{bracketed ? ']' : ')'}"
77
+ end
78
+
79
+ contents = members.join(sep_str(nil))
80
+ bracketed ? "[#{contents}]" : contents
63
81
  end
64
82
 
65
83
  # @see Value#to_h
66
84
  def to_h
67
- return Sass::Util.ordered_hash if value.empty?
85
+ return {} if value.empty?
68
86
  super
69
87
  end
70
88
 
71
89
  # @see Value#inspect
72
90
  def inspect
73
- "(#{value.map {|e| e.inspect}.join(sep_str(nil))})"
91
+ (bracketed ? '[' : '(') +
92
+ value.map {|e| e.inspect}.join(sep_str(nil)) +
93
+ (bracketed ? ']' : ')')
74
94
  end
75
95
 
76
96
  # Asserts an index is within the list.
@@ -94,9 +114,10 @@ module Sass::Script::Value
94
114
 
95
115
  def element_needs_parens?(element)
96
116
  if element.is_a?(List)
97
- return false if element.value.empty?
98
- precedence = Sass::Script::Parser.precedence_of(separator)
99
- return Sass::Script::Parser.precedence_of(element.separator) <= precedence
117
+ return false if element.value.length < 2
118
+ return false if element.bracketed
119
+ precedence = Sass::Script::Parser.precedence_of(separator || :space)
120
+ return Sass::Script::Parser.precedence_of(element.separator || :space) <= precedence
100
121
  end
101
122
 
102
123
  return false unless separator == :space
@@ -12,7 +12,7 @@ module Sass::Script::Value
12
12
  #
13
13
  # @param hash [Hash<Node, Node>]
14
14
  def initialize(hash)
15
- super(Sass::Util.ordered_hash(hash))
15
+ super(hash)
16
16
  end
17
17
 
18
18
  # @see Value#options=
@@ -32,7 +32,7 @@ module Sass::Script::Value
32
32
  # @see Value#to_a
33
33
  def to_a
34
34
  value.map do |k, v|
35
- list = List.new([k, v], :space)
35
+ list = List.new([k, v], separator: :space)
36
36
  list.options = options
37
37
  list
38
38
  end
@@ -306,7 +306,7 @@ module Sass::Script::Value
306
306
  end
307
307
  alias_method :to_sass, :inspect
308
308
 
309
- # @return [Integer] The integer value of the number
309
+ # @return [Fixnum] The integer value of the number
310
310
  # @raise [Sass::SyntaxError] if the number isn't an integer
311
311
  def to_i
312
312
  super unless int?
@@ -510,8 +510,8 @@ module Sass::Script::Value
510
510
  },
511
511
  {
512
512
  'dpi' => Rational(1),
513
- 'dpcm' => Rational(254, 100),
514
- 'dppx' => Rational(96)
513
+ 'dpcm' => Rational(1, 2.54),
514
+ 'dppx' => Rational(1, 96)
515
515
  }
516
516
  ]
517
517
 
@@ -2,8 +2,6 @@
2
2
  module Sass::Script::Value
3
3
  # A SassScript object representing a CSS string *or* a CSS identifier.
4
4
  class String < Base
5
- @@interpolation_deprecation = Sass::Deprecation.new
6
-
7
5
  # The Ruby value of the string.
8
6
  #
9
7
  # @return [String]
@@ -123,9 +121,18 @@ module Sass::Script::Value
123
121
  def check_deprecated_interp
124
122
  return unless @deprecated_interp_equivalent
125
123
 
126
- @@interpolation_deprecation.warn(source_range.file, source_range.start_pos.line, <<WARNING)
127
- \#{} interpolation near operators will be simplified in a future version of Sass.
128
- To preserve the current behavior, use quotes:
124
+ # rubocop:disable GlobalVars
125
+ $_sass_deprecated_interp_warnings ||= Set.new
126
+ key = [source_range.start_pos.line, source_range.file, @deprecated_interp_equivalent]
127
+ return if $_sass_deprecated_interp_warnings.include?(key)
128
+ $_sass_deprecated_interp_warnings << key
129
+ # rubocop:enable GlobalVars
130
+
131
+ location = "on line #{source_range.start_pos.line}"
132
+ location << " of #{source_range.file}" if source_range.file
133
+ Sass::Util.sass_warn <<WARNING
134
+ DEPRECATION WARNING #{location}: \#{} interpolation near operators will be simplified
135
+ in a future version of Sass. To preserve the current behavior, use quotes:
129
136
 
130
137
  #{@deprecated_interp_equivalent}
131
138
  WARNING
@@ -16,9 +16,9 @@ module Sass
16
16
  # warnings and source maps.
17
17
  # @param importer [Sass::Importers::Base] The importer used to import the
18
18
  # file being parsed. Used for source maps.
19
- # @param line [Integer] The 1-based line on which the source string appeared,
19
+ # @param line [Fixnum] The 1-based line on which the source string appeared,
20
20
  # if it's part of another document.
21
- # @param offset [Integer] The 1-based character (not byte) offset in the line on
21
+ # @param offset [Fixnum] The 1-based character (not byte) offset in the line on
22
22
  # which the source string starts. Used for error reporting and sourcemap
23
23
  # building.
24
24
  def initialize(str, filename, importer, line = 1, offset = 1)
@@ -99,6 +99,18 @@ module Sass
99
99
  condition
100
100
  end
101
101
 
102
+ # Parses a custom property value.
103
+ #
104
+ # @return [Array<String, Sass::Script;:Tree::Node>] The interpolated value.
105
+ # @raise [Sass::SyntaxError] if there's a syntax error in the value,
106
+ # or if it doesn't take up the entire input string.
107
+ def parse_declaration_value
108
+ init_scanner!
109
+ value = declaration_value
110
+ expected('"}"') unless value && @scanner.eos?
111
+ value
112
+ end
113
+
102
114
  private
103
115
 
104
116
  include Sass::SCSS::RX
@@ -767,6 +779,12 @@ module Sass
767
779
  mid = [str {ss}]
768
780
  return name + mid unless tok(/:/)
769
781
  mid << ':'
782
+
783
+ # If this is a CSS variable, parse it as a property no matter what.
784
+ if name.first.is_a?(String) && name.first.start_with?("--")
785
+ return css_variable_declaration(name, name_start_pos, name_end_pos)
786
+ end
787
+
770
788
  return name + mid + [':'] if tok(/:/)
771
789
  mid << str {ss}
772
790
  post_colon_whitespace = !mid.last.empty?
@@ -775,7 +793,7 @@ module Sass
775
793
  value_start_pos = source_position
776
794
  value = nil
777
795
  error = catch_error do
778
- value = value!(name.first.is_a?(String) && name.first.start_with?("--"))
796
+ value = value!
779
797
  if tok?(/\{/)
780
798
  # Properties that are ambiguous with selectors can't have additional
781
799
  # properties nested beneath them.
@@ -802,7 +820,7 @@ module Sass
802
820
  ss
803
821
  require_block = tok?(/\{/)
804
822
 
805
- node = node(Sass::Tree::PropNode.new(name.flatten.compact, value, :new),
823
+ node = node(Sass::Tree::PropNode.new(name.flatten.compact, [value], :new),
806
824
  name_start_pos, value_end_pos)
807
825
  node.name_source_range = range(name_start_pos, name_end_pos)
808
826
  node.value_source_range = range(value_start_pos, value_end_pos)
@@ -811,13 +829,21 @@ module Sass
811
829
  nested_properties! node
812
830
  end
813
831
 
814
- # This production is similar to the CSS [`<any-value>`][any-value]
815
- # production, but as the name implies, not quite the same. It's meant to
816
- # consume values that could be a selector, an expression, or a combination
817
- # of both. It respects strings and comments and supports interpolation. It
818
- # will consume up to "{", "}", ";", or "!".
819
- #
820
- # [any-value]: http://dev.w3.org/csswg/css-variables/#typedef-any-value
832
+ def css_variable_declaration(name, name_start_pos, name_end_pos)
833
+ value_start_pos = source_position
834
+ value = declaration_value
835
+ value_end_pos = source_position
836
+
837
+ node = node(Sass::Tree::PropNode.new(name.flatten.compact, value, :new),
838
+ name_start_pos, value_end_pos)
839
+ node.name_source_range = range(name_start_pos, name_end_pos)
840
+ node.value_source_range = range(value_start_pos, value_end_pos)
841
+ node
842
+ end
843
+
844
+ # This production consumes values that could be a selector, an expression,
845
+ # or a combination of both. It respects strings and comments and supports
846
+ # interpolation. It will consume up to "{", "}", ";", or "!".
821
847
  #
822
848
  # Values consumed by this production will usually be parsed more
823
849
  # thoroughly once interpolation has been resolved.
@@ -837,9 +863,6 @@ module Sass
837
863
  |
838
864
  (?!url\()
839
865
  [^"'/\#!;\{\}] # "
840
- |
841
- # interp_uri will handle most url() calls, but not ones that take strings
842
- url\(#{W}(?=")
843
866
  |
844
867
  /(?![/*])
845
868
  |
@@ -851,6 +874,60 @@ module Sass
851
874
  interpolation(:warn_for_color)
852
875
  end
853
876
 
877
+ def declaration_value(top_level: true)
878
+ return unless (tok = declaration_value_token(top_level))
879
+ value = [tok]
880
+ while (tok = declaration_value_token(top_level))
881
+ value << tok
882
+ end
883
+ merge(value)
884
+ end
885
+
886
+ def declaration_value_token(top_level)
887
+ # This comes, more or less, from the [token consumption algorithm][].
888
+ # However, since we don't have to worry about the token semantics, we
889
+ # just consume everything until we come across a token with special
890
+ # semantics.
891
+ #
892
+ # [token consumption algorithm]: https://drafts.csswg.org/css-syntax-3/#consume-token.
893
+ result = tok(%r{
894
+ (
895
+ (?!
896
+ url\(
897
+ )
898
+ [^()\[\]{}"'#/ \t\r\n\f#{top_level ? ";!" : ""}]
899
+ |
900
+ \#(?!\{)
901
+ |
902
+ /(?!\*)
903
+ )+
904
+ }xi) || interp_string || interp_uri || interpolation || tok(COMMENT)
905
+ return result if result
906
+
907
+ # Fold together multiple characters of whitespace that don't include
908
+ # newlines. The value only cares about the tokenization, so this is safe
909
+ # as long as we don't delete whitespace entirely. It's important that we
910
+ # fold here rather than post-processing, since we aren't allowed to fold
911
+ # whitespace within strings and we lose that context later on.
912
+ if (ws = tok(S))
913
+ return ws.include?("\n") ? ws.gsub(/\A[^\n]*/, '') : ' '
914
+ end
915
+
916
+ if tok(/\(/)
917
+ value = declaration_value(top_level: false)
918
+ tok!(/\)/)
919
+ ['(', *value, ')']
920
+ elsif tok(/\[/)
921
+ value = declaration_value(top_level: false)
922
+ tok!(/\]/)
923
+ ['[', *value, ']']
924
+ elsif tok(/\{/)
925
+ value = declaration_value(top_level: false)
926
+ tok!(/\}/)
927
+ ['{', *value, '}']
928
+ end
929
+ end
930
+
854
931
  def declaration
855
932
  # This allows the "*prop: val", ":prop: val", "#prop: val", and ".prop:
856
933
  # val" hacks.
@@ -871,12 +948,12 @@ module Sass
871
948
  tok!(/:/)
872
949
  ss
873
950
  value_start_pos = source_position
874
- value = value!(name.first.is_a?(String) && name.first.start_with?("--"))
951
+ value = value!
875
952
  value_end_pos = source_position
876
953
  ss
877
954
  require_block = tok?(/\{/)
878
955
 
879
- node = node(Sass::Tree::PropNode.new(name.flatten.compact, value, :new),
956
+ node = node(Sass::Tree::PropNode.new(name.flatten.compact, [value], :new),
880
957
  name_start_pos, value_end_pos)
881
958
  node.name_source_range = range(name_start_pos, name_end_pos)
882
959
  node.value_source_range = range(value_start_pos, value_end_pos)
@@ -885,7 +962,7 @@ module Sass
885
962
  nested_properties! node
886
963
  end
887
964
 
888
- def value!(css_variable = false)
965
+ def value!
889
966
  if tok?(/\{/)
890
967
  str = Sass::Script::Tree::Literal.new(Sass::Script::Value::String.new(""))
891
968
  str.line = source_position.line
@@ -899,25 +976,16 @@ module Sass
899
976
  # we don't parse it at all, and instead return a plain old string
900
977
  # containing the value.
901
978
  # This results in a dramatic speed increase.
902
- if (val = tok(STATIC_VALUE, true))
979
+ if (val = tok(STATIC_VALUE))
903
980
  str = Sass::Script::Tree::Literal.new(Sass::Script::Value::String.new(val.strip))
904
981
  str.line = start_pos.line
905
982
  str.source_range = range(start_pos)
906
983
  return str
907
984
  end
908
-
909
- sass_script(:parse, css_variable)
985
+ sass_script(:parse)
910
986
  end
911
987
 
912
988
  def nested_properties!(node)
913
- if node.name.first.is_a?(String) && node.name.first.start_with?("--")
914
- Sass::Util.sass_warn(<<WARNING)
915
- DEPRECATION WARNING on line #{@line}#{" of #{@filename}" if @filename}:
916
- Sass 3.6 will change the way CSS variables are parsed. Instead of being parsed as
917
- normal properties, they will not allow any Sass-specific behavior other than \#{}.
918
- WARNING
919
- end
920
-
921
989
  @expected = 'expression (e.g. 1px, bold) or "{"'
922
990
  block(node, :property)
923
991
  end
@@ -1005,7 +1073,7 @@ WARNING
1005
1073
  end
1006
1074
 
1007
1075
  def interp_ident(start = IDENT)
1008
- val = tok(start) || interpolation(:warn_for_color) || tok(IDENT_HYPHEN_INTERP, true)
1076
+ val = tok(start) || interpolation(:warn_for_color) || tok(IDENT_HYPHEN_INTERP)
1009
1077
  return unless val
1010
1078
  res = [val]
1011
1079
  while (val = tok(NAME) || interpolation(:warn_for_color))
@@ -1022,7 +1090,7 @@ WARNING
1022
1090
  end
1023
1091
 
1024
1092
  def str
1025
- @strs.push String.new("")
1093
+ @strs.push ""
1026
1094
  yield
1027
1095
  @strs.last
1028
1096
  ensure
@@ -1099,9 +1167,9 @@ WARNING
1099
1167
  :keyframes_selector => "keyframes selector (e.g. 10%)"
1100
1168
  }
1101
1169
 
1102
- TOK_NAMES = Sass::Util.to_hash(Sass::SCSS::RX.constants.map do |c|
1170
+ TOK_NAMES = Hash[Sass::SCSS::RX.constants.map do |c|
1103
1171
  [Sass::SCSS::RX.const_get(c), c.downcase]
1104
- end).merge(
1172
+ end].merge(
1105
1173
  IDENT => "identifier",
1106
1174
  /[;{}]/ => '";"',
1107
1175
  /\b(without|with)\b/ => '"with" or "without"'
@@ -1213,23 +1281,11 @@ WARNING
1213
1281
  # This is important because `#tok` is called all the time.
1214
1282
  NEWLINE = "\n"
1215
1283
 
1216
- def tok(rx, last_group_lookahead = false)
1284
+ def tok(rx)
1217
1285
  res = @scanner.scan(rx)
1218
1286
 
1219
1287
  return unless res
1220
1288
 
1221
- # This fixes https://github.com/nex3/sass/issues/104, which affects
1222
- # Ruby 1.8.7 and REE. This fix is to replace the ?= zero-width
1223
- # positive lookahead operator in the Regexp (which matches without
1224
- # consuming the matched group), with a match that does consume the
1225
- # group, but then rewinds the scanner and removes the group from the
1226
- # end of the matched string. This fix makes the assumption that the
1227
- # matched group will always occur at the end of the match.
1228
- if last_group_lookahead && @scanner[-1]
1229
- @scanner.pos -= @scanner[-1].length
1230
- res.slice!(-@scanner[-1].length..-1)
1231
- end
1232
-
1233
1289
  newline_count = res.count(NEWLINE)
1234
1290
  if newline_count > 0
1235
1291
  @line += newline_count
@@ -32,7 +32,7 @@ module Sass
32
32
  # @return [String] The escaped character
33
33
  # @private
34
34
  def self.escape_char(c)
35
- return "\\%06x" % (Sass::Util.ord(c)) unless c =~ %r{[ -/:-~]}
35
+ return "\\%06x" % c.ord unless c =~ %r{[ -/:-~]}
36
36
  "\\#{c}"
37
37
  end
38
38
 
@@ -40,7 +40,7 @@ module Sass
40
40
  # escaping all significant characters.
41
41
  #
42
42
  # @param str [String] The text of the regexp
43
- # @param flags [Integer] Flags for the created regular expression
43
+ # @param flags [Fixnum] Flags for the created regular expression
44
44
  # @return [Regexp]
45
45
  # @private
46
46
  def self.quote(str, flags = 0)
@@ -50,13 +50,7 @@ module Sass
50
50
  H = /[0-9a-fA-F]/
51
51
  NL = /\n|\r\n|\r|\f/
52
52
  UNICODE = /\\#{H}{1,6}[ \t\r\n\f]?/
53
- s = if Sass::Util.ruby1_8?
54
- '\200-\377'
55
- elsif Sass::Util.macruby?
56
- '\u0080-\uD7FF\uE000-\uFFFD\U00010000-\U0010FFFF'
57
- else
58
- '\u{80}-\u{D7FF}\u{E000}-\u{FFFD}\u{10000}-\u{10FFFF}'
59
- end
53
+ s = '\u{80}-\u{D7FF}\u{E000}-\u{FFFD}\u{10000}-\u{10FFFF}'
60
54
  NONASCII = /[#{s}]/
61
55
  ESCAPE = /#{UNICODE}|\\[ -~#{s}]/
62
56
  NMSTART = /[_a-zA-Z]|#{NONASCII}|#{ESCAPE}/
@@ -127,13 +121,13 @@ module Sass
127
121
  OPTIONAL = /!#{W}optional/i
128
122
  IDENT_START = /-|#{NMSTART}/
129
123
 
130
- IDENT_HYPHEN_INTERP = /-(#\{)/
124
+ IDENT_HYPHEN_INTERP = /-(?=#\{)/
131
125
  STRING1_NOINTERP = /\"((?:[^\n\r\f\\"#]|#(?!\{)|#{ESCAPE})*)\"/
132
126
  STRING2_NOINTERP = /\'((?:[^\n\r\f\\'#]|#(?!\{)|#{ESCAPE})*)\'/
133
127
  STRING_NOINTERP = /#{STRING1_NOINTERP}|#{STRING2_NOINTERP}/
134
128
 
135
129
  STATIC_COMPONENT = /#{IDENT}|#{STRING_NOINTERP}|#{HEXCOLOR}|[+-]?#{NUMBER}|\!important/i
136
- STATIC_VALUE = %r(#{STATIC_COMPONENT}(\s*[\s,/]\s*#{STATIC_COMPONENT})*([;}]))i
130
+ STATIC_VALUE = %r(#{STATIC_COMPONENT}(\s*[\s,\/]\s*#{STATIC_COMPONENT})*(?=[;}]))i
137
131
  STATIC_SELECTOR = /(#{NMCHAR}|[ \t]|[,>+*]|[:#.]#{NMSTART}){1,50}([{])/i
138
132
  end
139
133
  end