sass 3.3.0.alpha.198 → 3.3.0.alpha.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/REVISION +1 -1
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/lib/sass/script/functions.rb +33 -2
- data/lib/sass/script/tree/funcall.rb +1 -1
- data/test/sass/functions_test.rb +35 -0
- metadata +4 -4
data/REVISION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3a64325d2550f0bc57f6490854c0a7d0bc5c9db5
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.3.0.alpha.
|
|
1
|
+
3.3.0.alpha.201
|
data/VERSION_DATE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
17 July 2013 20:29:34 GMT
|
|
@@ -192,6 +192,9 @@ module Sass::Script
|
|
|
192
192
|
# \{#comparable comparable($number-1, $number-2)}
|
|
193
193
|
# : Returns whether two numbers can be added, subtracted, or compared.
|
|
194
194
|
#
|
|
195
|
+
# \{#call call($name, $args...)}
|
|
196
|
+
# : Dynamically calls a Sass function.
|
|
197
|
+
#
|
|
195
198
|
# ## Miscellaneous Functions
|
|
196
199
|
#
|
|
197
200
|
# \{#if if($condition, $if-true, $if-false)}
|
|
@@ -408,8 +411,9 @@ module Sass::Script
|
|
|
408
411
|
# Asserts that the value is an integer.
|
|
409
412
|
#
|
|
410
413
|
# @example
|
|
411
|
-
#
|
|
412
|
-
#
|
|
414
|
+
# assert_integer 2px
|
|
415
|
+
# assert_integer 2.5px => SyntaxError: "Expected 2.5px to be an integer"
|
|
416
|
+
# assert_integer 2.5px, "width" => SyntaxError: "Expected width to be an integer but got 2.5px"
|
|
413
417
|
# @param number [Sass::Script::Value::Base] The value to be validated.
|
|
414
418
|
# @param name [::String] The name of the parameter being validated.
|
|
415
419
|
# @raise [ArgumentError] if number is not an integer or is not a number.
|
|
@@ -1781,6 +1785,33 @@ module Sass::Script
|
|
|
1781
1785
|
end
|
|
1782
1786
|
declare :unique_id, []
|
|
1783
1787
|
|
|
1788
|
+
# Dynamically calls a function. This can call user-defined
|
|
1789
|
+
# functions, built-in functions, or plain CSS functions. It will
|
|
1790
|
+
# pass along all arguments, including keyword arguments, to the
|
|
1791
|
+
# called function.
|
|
1792
|
+
#
|
|
1793
|
+
# @example
|
|
1794
|
+
# call(rgb, 10, 100, 255) => #0a64ff
|
|
1795
|
+
# call(scale-color, #0a64ff, $lightness: -10%) => #0058ef
|
|
1796
|
+
#
|
|
1797
|
+
# $fn: nth;
|
|
1798
|
+
# call($fn, 2, (a b c)) => b
|
|
1799
|
+
#
|
|
1800
|
+
# @overload call($name, $args...)
|
|
1801
|
+
# @param $name [String] The name of the function to call.
|
|
1802
|
+
def call(name, *args)
|
|
1803
|
+
assert_type name, :String, :name
|
|
1804
|
+
kwargs = args.last.is_a?(Hash) ? args.pop : {}
|
|
1805
|
+
funcall = Sass::Script::Tree::Funcall.new(
|
|
1806
|
+
name.value,
|
|
1807
|
+
args.map {|a| Sass::Script::Tree::Literal.new(a)},
|
|
1808
|
+
Sass::Util.map_vals(kwargs) {|v| Sass::Script::Tree::Literal.new(v)},
|
|
1809
|
+
nil)
|
|
1810
|
+
funcall.options = options
|
|
1811
|
+
funcall.perform(environment)
|
|
1812
|
+
end
|
|
1813
|
+
declare :call, [:name], :var_args => true, :var_kwargs => true
|
|
1814
|
+
|
|
1784
1815
|
# This function only exists as a workaround for IE7's [`content:counter`
|
|
1785
1816
|
# bug](http://jes.st/2013/ie7s-css-breaking-content-counter-bug/).
|
|
1786
1817
|
# It works identically to any other plain-CSS function, except it
|
|
@@ -205,7 +205,7 @@ module Sass::Script::Tree
|
|
|
205
205
|
return args
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
-
args = args + signature.args[args.size..-1].map do |argname|
|
|
208
|
+
args = args + (signature.args[args.size..-1] || []).map do |argname|
|
|
209
209
|
if keywords.has_key?(argname)
|
|
210
210
|
keywords.delete(argname)
|
|
211
211
|
else
|
data/test/sass/functions_test.rb
CHANGED
|
@@ -1258,6 +1258,41 @@ MSG
|
|
|
1258
1258
|
end
|
|
1259
1259
|
end
|
|
1260
1260
|
|
|
1261
|
+
def test_call_with_positional_arguments
|
|
1262
|
+
assert_equal evaluate("lighten(blue, 5%)"), evaluate("call(lighten, blue, 5%)")
|
|
1263
|
+
end
|
|
1264
|
+
|
|
1265
|
+
def test_call_with_keyword_arguments
|
|
1266
|
+
assert_equal(
|
|
1267
|
+
evaluate("lighten($color: blue, $amount: 5%)"),
|
|
1268
|
+
evaluate("call(lighten, $color: blue, $amount: 5%)"))
|
|
1269
|
+
end
|
|
1270
|
+
|
|
1271
|
+
def test_call_with_keyword_and_positional_arguments
|
|
1272
|
+
assert_equal(
|
|
1273
|
+
evaluate("lighten(blue, $amount: 5%)"),
|
|
1274
|
+
evaluate("call(lighten, blue, $amount: 5%)"))
|
|
1275
|
+
end
|
|
1276
|
+
|
|
1277
|
+
def test_call_with_dynamic_name
|
|
1278
|
+
assert_equal(
|
|
1279
|
+
evaluate("lighten($color: blue, $amount: 5%)"),
|
|
1280
|
+
evaluate("call($fn, $color: blue, $amount: 5%)",
|
|
1281
|
+
env("fn" => Sass::Script::String.new("lighten"))))
|
|
1282
|
+
end
|
|
1283
|
+
|
|
1284
|
+
def test_call_unknown_function
|
|
1285
|
+
assert_equal evaluate("unknown(red, blue)"), evaluate("call(unknown, red, blue)")
|
|
1286
|
+
end
|
|
1287
|
+
|
|
1288
|
+
def test_call_with_non_string_argument
|
|
1289
|
+
assert_error_message "$name: 3px is not a string for `call'", "call(3px)"
|
|
1290
|
+
end
|
|
1291
|
+
|
|
1292
|
+
def test_errors_in_called_function
|
|
1293
|
+
assert_error_message "3px is not a color for `lighten'", "call(lighten, 3px, 5%)"
|
|
1294
|
+
end
|
|
1295
|
+
|
|
1261
1296
|
## Regression Tests
|
|
1262
1297
|
|
|
1263
1298
|
def test_saturation_bounds
|
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:
|
|
4
|
+
hash: 592302751
|
|
5
5
|
prerelease: 6
|
|
6
6
|
segments:
|
|
7
7
|
- 3
|
|
8
8
|
- 3
|
|
9
9
|
- 0
|
|
10
10
|
- alpha
|
|
11
|
-
-
|
|
12
|
-
version: 3.3.0.alpha.
|
|
11
|
+
- 201
|
|
12
|
+
version: 3.3.0.alpha.201
|
|
13
13
|
platform: ruby
|
|
14
14
|
authors:
|
|
15
15
|
- Nathan Weizenbaum
|
|
@@ -19,7 +19,7 @@ autorequire:
|
|
|
19
19
|
bindir: bin
|
|
20
20
|
cert_chain: []
|
|
21
21
|
|
|
22
|
-
date: 2013-07-
|
|
22
|
+
date: 2013-07-17 00:00:00 -04:00
|
|
23
23
|
default_executable:
|
|
24
24
|
dependencies:
|
|
25
25
|
- !ruby/object:Gem::Dependency
|