sass 3.3.0.alpha.380 → 3.3.0.alpha.382

Sign up to get free protection for your applications and to get access to all the features.
data/REVISION CHANGED
@@ -1 +1 @@
1
- 898bec6bfb7fa4ce8a1ca8e2ff210387c7f98f0e
1
+ bdc463148ed78f460943d6872b3e45109fe894ed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0.alpha.380
1
+ 3.3.0.alpha.382
data/VERSION_DATE CHANGED
@@ -1 +1 @@
1
- 11 October 2013 22:11:57 GMT
1
+ 11 October 2013 22:12:53 GMT
@@ -269,7 +269,8 @@ RUBY
269
269
  key, value = map_pair(e)
270
270
  map = node(Sass::Script::Tree::MapLiteral.new([[key, value]]), start_pos)
271
271
  while try_tok(:comma)
272
- key, value = assert_expr(:map_pair)
272
+ return map unless (pair = map_pair)
273
+ key, value = pair
273
274
  map.pairs << [key, value]
274
275
  end
275
276
  map
@@ -289,16 +290,20 @@ RUBY
289
290
  end
290
291
 
291
292
  def list(first, start_pos)
293
+ return first unless @lexer.peek && @lexer.peek.type == :comma
294
+
292
295
  list = node(Sass::Script::Tree::ListLiteral.new([first], :comma), start_pos)
293
296
  while (tok = try_tok(:comma))
294
- if (interp = try_op_before_interp(tok, list))
297
+ element_before_interp = list.elements.length == 1 ? list.elements.first : list
298
+ if (interp = try_op_before_interp(tok, element_before_interp))
295
299
  other_interp = try_ops_after_interp([:comma], :expr, interp)
296
300
  return interp unless other_interp
297
301
  return other_interp
298
302
  end
299
- list.elements << assert_expr(:interpolation)
303
+ return list unless (e = interpolation)
304
+ list.elements << e
300
305
  end
301
- list.elements.size == 1 ? list.elements.first : list
306
+ list
302
307
  end
303
308
 
304
309
  production :equals, :interpolation, :single_eq
@@ -29,7 +29,7 @@ module Sass::Script::Tree
29
29
  def to_sass(opts = {})
30
30
  return "()" if elements.empty?
31
31
  precedence = Sass::Script::Parser.precedence_of(separator)
32
- elements.reject {|e| e.is_a?(Sass::Script::Value::Null)}.map do |v|
32
+ members = elements.map do |v|
33
33
  if v.is_a?(ListLiteral) && Sass::Script::Parser.precedence_of(v.separator) <= precedence ||
34
34
  separator == :space && v.is_a?(UnaryOperation) &&
35
35
  (v.operator == :minus || v.operator == :plus)
@@ -37,7 +37,11 @@ module Sass::Script::Tree
37
37
  else
38
38
  v.to_sass(opts)
39
39
  end
40
- end.join(sep_str(nil))
40
+ end
41
+
42
+ return "(#{members.first},)" if separator == :comma && members.length == 1
43
+
44
+ members.join(sep_str(nil))
41
45
  end
42
46
 
43
47
 
@@ -52,7 +52,7 @@ module Sass::Script::Value
52
52
  def to_sass(opts = {})
53
53
  return "()" if value.empty?
54
54
  precedence = Sass::Script::Parser.precedence_of(separator)
55
- value.reject {|e| e.is_a?(Null)}.map do |v|
55
+ members = value.reject {|e| e.is_a?(Null)}.map do |v|
56
56
  if v.is_a?(List) && Sass::Script::Parser.precedence_of(v.separator) <= precedence ||
57
57
  separator == :space && v.is_a?(Sass::Script::Tree::UnaryOperation) &&
58
58
  (v.operator == :minus || v.operator == :plus)
@@ -60,7 +60,9 @@ module Sass::Script::Value
60
60
  else
61
61
  v.to_sass(opts)
62
62
  end
63
- end.join(sep_str(nil))
63
+ end
64
+ return "(#{members.first},)" if members.length == 1 && separator == :comma
65
+ members.join(sep_str(nil))
64
66
  end
65
67
 
66
68
  # @see Value#to_h
@@ -83,6 +83,12 @@ class SassScriptConversionTest < Test::Unit::TestCase
83
83
  assert_renders "foo(a, b, (a, b, c)...)"
84
84
  end
85
85
 
86
+ def test_singleton_list
87
+ assert_renders "(1,)"
88
+ assert_renders "(1 2 3,)"
89
+ assert_renders "((1, 2, 3),)"
90
+ end
91
+
86
92
  def test_map
87
93
  assert_renders "(foo: bar)"
88
94
  assert_renders "(foo: bar, baz: bip)"
@@ -492,6 +492,18 @@ SASS
492
492
  assert_equal "1 2 3", resolve("null 1 2 3")
493
493
  end
494
494
 
495
+ def test_map_can_have_trailing_comma
496
+ assert_equal("(foo: 1, bar: 2)", eval("(foo: 1, bar: 2,)").to_sass)
497
+ end
498
+
499
+ def test_list_can_have_trailing_comma
500
+ assert_equal("1, 2, 3", resolve("1, 2, 3,"))
501
+ end
502
+
503
+ def test_trailing_comma_defines_singleton_list
504
+ assert_equal("1 2 3", resolve("nth((1 2 3,), 1)"))
505
+ end
506
+
495
507
  def test_map_cannot_have_duplicate_keys
496
508
  assert_raise_message(Sass::SyntaxError, 'Duplicate key "foo" in map (foo: bar, foo: baz).') do
497
509
  eval("(foo: bar, foo: baz)")
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass
3
3
  version: !ruby/object:Gem::Version
4
- hash: 592302581
4
+ hash: 592302577
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 3
9
9
  - 0
10
10
  - alpha
11
- - 380
12
- version: 3.3.0.alpha.380
11
+ - 382
12
+ version: 3.3.0.alpha.382
13
13
  platform: ruby
14
14
  authors:
15
15
  - Nathan Weizenbaum