Permalink
Browse files

Allow interpolation to come immediately after a hyphen in identifiers.

Closes gh-198
  • Loading branch information...
1 parent 8492ac6 commit d5ec0586cd5cf40c31c5d99abf740a3b83204b5d @nex3 nex3 committed Nov 23, 2011
Showing with 12 additions and 1 deletion.
  1. +1 −0 doc-src/SASS_CHANGELOG.md
  2. +1 −1 lib/sass/scss/parser.rb
  3. +1 −0 lib/sass/scss/rx.rb
  4. +9 −0 test/sass/scss/scss_test.rb
@@ -6,6 +6,7 @@
## 3.1.11 (Unreleased)
* Allow control directives (such as `@if`) to be nested beneath properties.
+* Allow property names to begin with a hyphen followed by interpolation (e.g. `-#{...}`).
* Make `--cache-store` with with `--update`.
* Properly report `ArgumentError`s that occur within user-defined functions.
* Don't crash on JRuby if the underlying Java doesn't support every Unicode encoding.
View
@@ -770,7 +770,7 @@ def _interp_string(type)
end
def interp_ident(start = IDENT)
- return unless val = tok(start) || interpolation
+ return unless val = tok(start) || interpolation || tok(IDENT_HYPHEN_INTERP)
res = [val]
while val = tok(NAME) || interpolation
res << val
View
@@ -112,6 +112,7 @@ def self.quote(str, flags = 0)
INTERP_START = /#\{/
MOZ_ANY = quote(":-moz-any(", Regexp::IGNORECASE)
+ IDENT_HYPHEN_INTERP = /-(?=#\{)/
STRING1_NOINTERP = /\"((?:[^\n\r\f\\"#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\"/
STRING2_NOINTERP = /\'((?:[^\n\r\f\\'#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\'/
STRING_NOINTERP = /#{STRING1_NOINTERP}|#{STRING2_NOINTERP}/
@@ -1095,6 +1095,15 @@ def test_no_lonely_else
# Regression
+ def test_prop_name_interpolation_after_hyphen
+ assert_equal <<CSS, render(<<SCSS)
+a {
+ -foo-bar: b; }
+CSS
+a { -\#{"foo"}-bar: b; }
+SCSS
+ end
+
def test_star_plus_and_parent
assert_equal <<CSS, render(<<SCSS)
* + html foo {

0 comments on commit d5ec058

Please sign in to comment.