Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid IE7's content: counter bug.

Closes #744
  • Loading branch information...
commit 1556fe288b5aa96a777291a208998deb31522a33 1 parent d7277c4
@nex3 nex3 authored
View
4 doc-src/SASS_CHANGELOG.md
@@ -14,6 +14,10 @@
* Update the bundled version of [listen](http://github.com/guard/listen) to
0.7.3.
+* Automatically avoid the [IE7 `content: counter` bug][cc bug].
+
+[cc bug]: http://jes.st/2013/ie7s-css-breaking-content-counter-bug/
+
## 3.2.8
* Fix some edge cases where redundant selectors were emitted when using
View
13 lib/sass/script/functions.rb
@@ -1423,6 +1423,19 @@ def if(condition, if_true, if_false)
end
declare :if, [:condition, :if_true, :if_false]
+ # This function only exists as a workaround for IE7's [`content:counter`
+ # bug][bug]. It works identically to any other plain-CSS function, except it
+ # avoids adding spaces between the argument commas.
+ #
+ # [bug]: http://jes.st/2013/ie7s-css-breaking-content-counter-bug/
+ #
+ # @example
+ # counter(item, ".") => counter(item,".")
+ def counter(*args)
+ Sass::Script::String.new("counter(#{args.map {|a| a.to_s(options)}.join(',')})")
+ end
+ declare :counter, [], :var_args => true
+
private
# This method implements the pattern of transforming a numeric value into
View
6 test/sass/functions_test.rb
@@ -1037,6 +1037,12 @@ def test_if
assert_equal("2px", evaluate("if(null, 1px, 2px)"))
end
+ def test_counter
+ assert_equal("counter(foo)", evaluate("counter(foo)"))
+ assert_equal('counter(item,".")', evaluate('counter(item, ".")'))
+ assert_equal('counter(item,".")', evaluate('counter(item,".")'))
+ end
+
def test_keyword_args_rgb
assert_equal(%Q{white}, evaluate("rgb($red: 255, $green: 255, $blue: 255)"))
end
Please sign in to comment.
Something went wrong with that request. Please try again.