sass 3.3.0.alpha.165 → 3.3.0.alpha.167

Sign up to get free protection for your applications and to get access to all the features.
data/REVISION CHANGED
@@ -1 +1 @@
1
- 959ac903776876458b8c6cfb5abe4af45a6359a9
1
+ 9aaeedb21f108c9ee8ca496ed018fdf3b0c5bd19
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0.alpha.165
1
+ 3.3.0.alpha.167
data/VERSION_DATE CHANGED
@@ -1 +1 @@
1
- 03 June 2013 16:39:00 GMT
1
+ 03 June 2013 17:31:15 GMT
@@ -193,6 +193,9 @@ module Sass::Script
193
193
  # \{#if if($condition, $if-true, $if-false)}
194
194
  # : Returns one of two values, depending on whether or not a condition is true.
195
195
  #
196
+ # \{#unique-id unique-id()}
197
+ # : Returns a unique CSS identifier.
198
+ #
196
199
  # ## Adding Custom Functions
197
200
  #
198
201
  # New Sass functions can be added by adding Ruby methods to this module.
@@ -1653,6 +1656,20 @@ module Sass::Script
1653
1656
  end
1654
1657
  declare :if, [:condition, :if_true, :if_false]
1655
1658
 
1659
+ # Returns a unique string that is a legal CSS identifiers.
1660
+ # The unique value returned is only guaranteed to be unique within the scope
1661
+ # of a singe CSS file's output.
1662
+ def unique_id
1663
+ Thread.current[:sass_last_unique_id] ||= begin
1664
+ min = 78364164096 # 10000000 in base 36
1665
+ max = 156728328192 # 20000000 in base 36
1666
+ range = max - min
1667
+ rand(max - min) + min
1668
+ end
1669
+ value = (Thread.current[:sass_last_unique_id] += rand(10)) # avoid the temptation of trying to guess the next unique value.
1670
+ Sass::Script::String.new("u"+value.to_s(36)) # the u makes this a legal identifier if it starts with a number.
1671
+ end
1672
+
1656
1673
  # This function only exists as a workaround for IE7's [`content:counter`
1657
1674
  # bug][bug]. It works identically to any other plain-CSS function, except it
1658
1675
  # avoids adding spaces between the argument commas.
@@ -1197,6 +1197,11 @@ MSG
1197
1197
  assert_equal "only-kw-args(a, b, c)", evaluate("only-kw-args($a: 1, $b: 2, $c: 3)")
1198
1198
  end
1199
1199
 
1200
+ def test_unique_id
1201
+ assert_match(/u[a-z0-9]{8}/, evaluate("unique-id()"))
1202
+ assert evaluate("unique-id()") != evaluate("unique-id()")
1203
+ end
1204
+
1200
1205
  def test_assert_unit
1201
1206
  ctx = Sass::Script::Functions::EvaluationContext.new(Sass::Environment.new(nil, {}))
1202
1207
  ctx.assert_unit Sass::Script::Value::Number.new(10, ["px"], []), "px"
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: 592302663
4
+ hash: 592302659
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 3
9
9
  - 0
10
10
  - alpha
11
- - 165
12
- version: 3.3.0.alpha.165
11
+ - 167
12
+ version: 3.3.0.alpha.167
13
13
  platform: ruby
14
14
  authors:
15
15
  - Nathan Weizenbaum