sass 3.1.0.alpha.261 → 3.1.0.alpha.262
Sign up to get free protection for your applications and to get access to all the features.
- data/REVISION +1 -1
- data/VERSION +1 -1
- data/lib/sass/importers/filesystem.rb +3 -2
- data/lib/sass/plugin/staleness_checker.rb +1 -0
- data/lib/sass/script/functions.rb +4 -2
- data/lib/sass/script/list.rb +2 -1
- data/lib/sass/script/parser.rb +3 -2
- data/test/sass/functions_test.rb +27 -0
- data/test/sass/script_test.rb +8 -0
- metadata +1 -1
data/REVISION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
d9b9e527c5f56934fbf0db348796494ce5a7c576
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.0.alpha.
|
1
|
+
3.1.0.alpha.262
|
@@ -50,8 +50,9 @@ module Sass
|
|
50
50
|
# If a full uri is passed, this removes the root from it
|
51
51
|
# otherwise returns the name unchanged
|
52
52
|
def remove_root(name)
|
53
|
-
|
54
|
-
|
53
|
+
root = @root.end_with?('/') ? @root : @root + '/'
|
54
|
+
if name.index(root) == 0
|
55
|
+
name[root.length..-1]
|
55
56
|
else
|
56
57
|
name
|
57
58
|
end
|
@@ -54,6 +54,7 @@ module Sass
|
|
54
54
|
# that is compiled to `css_file`.
|
55
55
|
# @return [Boolean] Whether the stylesheet needs to be updated.
|
56
56
|
def stylesheet_needs_update?(css_file, template_file, importer = nil)
|
57
|
+
template_file = File.expand_path(template_file)
|
57
58
|
begin
|
58
59
|
css_mtime = File.mtime(css_file)
|
59
60
|
rescue Errno::ENOENT
|
@@ -1217,6 +1217,8 @@ module Sass::Script
|
|
1217
1217
|
raise ArgumentError.new("List index #{n} must be an integer")
|
1218
1218
|
elsif n.to_i < 1
|
1219
1219
|
raise ArgumentError.new("List index #{n} must be greater than or equal to 1")
|
1220
|
+
elsif list.to_a.size == 0
|
1221
|
+
raise ArgumentError.new("List index is #{n} but list has no items")
|
1220
1222
|
elsif n.to_i > (size = list.to_a.size)
|
1221
1223
|
raise ArgumentError.new("List index is #{n} but list is only #{size} item#{'s' if size != 1} long")
|
1222
1224
|
end
|
@@ -1249,8 +1251,8 @@ module Sass::Script
|
|
1249
1251
|
unless %w[auto space comma].include?(separator.value)
|
1250
1252
|
raise ArgumentError.new("Separator name must be space, comma, or auto")
|
1251
1253
|
end
|
1252
|
-
sep1 = list1.separator if list1.is_a?(Sass::Script::List)
|
1253
|
-
sep2 = list2.separator if list2.is_a?(Sass::Script::List)
|
1254
|
+
sep1 = list1.separator if list1.is_a?(Sass::Script::List) && !list1.value.empty?
|
1255
|
+
sep2 = list2.separator if list2.is_a?(Sass::Script::List) && !list2.value.empty?
|
1254
1256
|
Sass::Script::List.new(
|
1255
1257
|
list1.to_a + list2.to_a,
|
1256
1258
|
if separator.value == 'auto'
|
data/lib/sass/script/list.rb
CHANGED
@@ -33,7 +33,8 @@ module Sass::Script
|
|
33
33
|
|
34
34
|
# @see Node#to_s
|
35
35
|
def to_s(opts = {})
|
36
|
-
|
36
|
+
raise Sass::SyntaxError.new("() isn't a valid CSS value.") if value.empty?
|
37
|
+
return value.reject {|e| e.is_a?(List) && e.value.empty?}.map {|e| e.to_s(opts)}.join(sep_str)
|
37
38
|
end
|
38
39
|
|
39
40
|
# @see Node#to_sass
|
data/lib/sass/script/parser.rb
CHANGED
@@ -393,9 +393,10 @@ RUBY
|
|
393
393
|
return variable unless try_tok(:lparen)
|
394
394
|
was_in_parens = @in_parens
|
395
395
|
@in_parens = true
|
396
|
-
|
396
|
+
line = @lexer.line
|
397
|
+
e = expr
|
397
398
|
assert_tok(:rparen)
|
398
|
-
return e
|
399
|
+
return e || node(List.new([], :space), line)
|
399
400
|
ensure
|
400
401
|
@in_parens = was_in_parens
|
401
402
|
end
|
data/test/sass/functions_test.rb
CHANGED
@@ -875,6 +875,8 @@ MSG
|
|
875
875
|
assert_equal("3", evaluate("length((foo, bar, baz bip))"))
|
876
876
|
assert_equal("3", evaluate("length((foo, bar, (baz, bip)))"))
|
877
877
|
assert_equal("1", evaluate("length(#f00)"))
|
878
|
+
assert_equal("0", evaluate("length(())"))
|
879
|
+
assert_equal("4", evaluate("length(1 2 () 3)"))
|
878
880
|
end
|
879
881
|
|
880
882
|
def test_nth
|
@@ -888,6 +890,7 @@ MSG
|
|
888
890
|
assert_error_message("List index 1.5 must be an integer for `nth'", "nth(foo, 1.5)")
|
889
891
|
assert_error_message("List index is 5 but list is only 4 items long for `nth'", "nth(1 2 3 4, 5)")
|
890
892
|
assert_error_message("List index is 2 but list is only 1 item long for `nth'", "nth(foo, 2)")
|
893
|
+
assert_error_message("List index is 1 but list has no items for `nth'", "nth((), 1)")
|
891
894
|
end
|
892
895
|
|
893
896
|
def test_join
|
@@ -911,6 +914,20 @@ MSG
|
|
911
914
|
assert_equal("1 2 3 4", evaluate("join((1, 2), (3, 4), space)"))
|
912
915
|
assert_equal("1, 2", evaluate("join(1, 2, comma)"))
|
913
916
|
|
917
|
+
assert_equal("1 2", evaluate("join(1 2, ())"))
|
918
|
+
assert_equal("1, 2", evaluate("join((1, 2), ())"))
|
919
|
+
assert_equal("true", evaluate("(1 2) == join(1 2, ())"))
|
920
|
+
assert_equal("true", evaluate("(1, 2) == join((1, 2), ())"))
|
921
|
+
assert_equal("false", evaluate("(1 2 ()) == join(1 2, ())"))
|
922
|
+
assert_equal("false", evaluate("(1, 2, ()) == join((1, 2), ())"))
|
923
|
+
|
924
|
+
assert_equal("1 2", evaluate("join((), 1 2)"))
|
925
|
+
assert_equal("1, 2", evaluate("join((), (1, 2))"))
|
926
|
+
assert_equal("true", evaluate("(1 2) == join((), 1 2)"))
|
927
|
+
assert_equal("true", evaluate("(1, 2) == join((), (1, 2))"))
|
928
|
+
assert_equal("false", evaluate("(1 2 ()) == join((), 1 2)"))
|
929
|
+
assert_equal("false", evaluate("(1, 2, ()) == join((), (1, 2))"))
|
930
|
+
|
914
931
|
assert_error_message("Separator name must be space, comma, or auto for `join'", "join(1, 2, baboon)")
|
915
932
|
end
|
916
933
|
|
@@ -935,6 +952,16 @@ MSG
|
|
935
952
|
assert_equal("1 2 3, 4", evaluate("append((1, 2), (3, 4), space)"))
|
936
953
|
assert_equal("1, 2", evaluate("append(1, 2, comma)"))
|
937
954
|
|
955
|
+
assert_equal("1 2", evaluate("append(1 2, ())"))
|
956
|
+
assert_equal("1, 2", evaluate("append((1, 2), ())"))
|
957
|
+
assert_equal("true", evaluate("(1 2 ()) == append(1 2, ())"))
|
958
|
+
assert_equal("true", evaluate("(1, 2, ()) == append((1, 2), ())"))
|
959
|
+
|
960
|
+
assert_equal("1 2", evaluate("append((), 1 2)"))
|
961
|
+
assert_equal("1, 2", evaluate("append((), (1, 2))"))
|
962
|
+
assert_equal("false", evaluate("(1 2) == append((), 1 2)"))
|
963
|
+
assert_equal("true", evaluate("(1 2) == nth(append((), 1 2), 1)"))
|
964
|
+
|
938
965
|
assert_error_message("Separator name must be space, comma, or auto for `append'", "append(1, 2, baboon)")
|
939
966
|
end
|
940
967
|
|
data/test/sass/script_test.rb
CHANGED
@@ -406,6 +406,14 @@ SASS
|
|
406
406
|
assert_equal "#7f4000", resolve("mix(GrEeN, ReD)")
|
407
407
|
end
|
408
408
|
|
409
|
+
def test_empty_list
|
410
|
+
assert_equal "1 2 3", resolve("1 2 () 3")
|
411
|
+
assert_equal "1 2 3", resolve("1 2 3 ()")
|
412
|
+
assert_equal "1 2 3", resolve("() 1 2 3")
|
413
|
+
assert_raise_message(Sass::SyntaxError, "() isn't a valid CSS value.") {resolve("()")}
|
414
|
+
assert_raise_message(Sass::SyntaxError, "() isn't a valid CSS value.") {resolve("nth(append((), ()), 1)")}
|
415
|
+
end
|
416
|
+
|
409
417
|
# Regression Tests
|
410
418
|
|
411
419
|
def test_funcall_has_higher_precedence_than_color_name
|