diff options
author | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2013-10-07 16:03:56 -0700 |
---|---|---|
committer | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2013-10-07 16:03:56 -0700 |
commit | 3a642158da561e238e6edebb53827a833add544f (patch) | |
tree | cdb88a571f68b28bf0be69415aeda75ca9eca1b2 | |
parent | 10c79d6f3e9dd586da907c4c288b7a06cc500abc (diff) | |
download | pyscss-3a642158da561e238e6edebb53827a833add544f.tar.gz |
Revert "Unquote strings when used from variables in selectors"
Diverges from Ruby behavior, and is causing a crash somewhere when run
against Yelp's codebase.
This reverts commit 431a1d1471de6d86dd8cdf66924a606fea0df60e.
-rw-r--r-- | scss/__init__.py | 2 | ||||
-rw-r--r-- | scss/expression.py | 8 | ||||
-rw-r--r-- | scss/tests/files/kronuz/selectors-unquoted.css | 3 | ||||
-rw-r--r-- | scss/tests/files/kronuz/selectors-unquoted.scss | 5 | ||||
-rw-r--r-- | scss/types.py | 25 |
5 files changed, 18 insertions, 25 deletions
diff --git a/scss/__init__.py b/scss/__init__.py index 6afa85c..fc5b440 100644 --- a/scss/__init__.py +++ b/scss/__init__.py @@ -1288,7 +1288,7 @@ class Scss(object): Implements Nested CSS rules """ calculator = Calculator(rule.namespace) - raw_selectors = calculator.do_glob_math(block.prop, unquote=True) + raw_selectors = calculator.do_glob_math(block.prop) # DEVIATION: ruby sass doesn't support bare variables in selectors raw_selectors = calculator.apply_vars(raw_selectors) c_selectors, c_parents = self.parse_selectors(raw_selectors) diff --git a/scss/expression.py b/scss/expression.py index 12c867a..cacd8ec 100644 --- a/scss/expression.py +++ b/scss/expression.py @@ -36,7 +36,7 @@ class Calculator(object): else: self.namespace = namespace - def _pound_substitute(self, result, unquote): + def _pound_substitute(self, result): expr = result.group(1) value = self.evaluate_expression(expr) @@ -45,9 +45,9 @@ class Calculator(object): elif value.is_null: return "" else: - return dequote(value.render(unquote=unquote)) + return dequote(value.render()) - def do_glob_math(self, cont, unquote=False): + def do_glob_math(self, cont): """Performs #{}-interpolation. The result is always treated as a fixed syntactic unit and will not be re-evaluated. """ @@ -55,7 +55,7 @@ class Calculator(object): cont = str(cont) if '#{' not in cont: return cont - cont = _expr_glob_re.sub(lambda r: self._pound_substitute(r, unquote), cont) + cont = _expr_glob_re.sub(self._pound_substitute, cont) return cont def apply_vars(self, cont): diff --git a/scss/tests/files/kronuz/selectors-unquoted.css b/scss/tests/files/kronuz/selectors-unquoted.css deleted file mode 100644 index bbdbf8e..0000000 --- a/scss/tests/files/kronuz/selectors-unquoted.css +++ /dev/null @@ -1,3 +0,0 @@ -p li.l1.current, p:hover li.l1.current, li.l1.current { - color: red; -} diff --git a/scss/tests/files/kronuz/selectors-unquoted.scss b/scss/tests/files/kronuz/selectors-unquoted.scss deleted file mode 100644 index 567f6a4..0000000 --- a/scss/tests/files/kronuz/selectors-unquoted.scss +++ /dev/null @@ -1,5 +0,0 @@ -@option style:legacy; - -#{append(nest('p, p:hover', 'li.l1.current'), 'li.l1.current')} { - color: red; -} diff --git a/scss/types.py b/scss/types.py index f34552c..7ef6dc3 100644 --- a/scss/types.py +++ b/scss/types.py @@ -101,7 +101,7 @@ class Value(object): def __neg__(self): return String("-" + self.render()) - def render(self, compress=False, unquote=False): + def render(self, compress=False): return self.__str__() @@ -130,7 +130,7 @@ class Null(Value): def __ne__(self, other): return Boolean(not self.__eq__(other)) - def render(self, compress=False, unquote=False): + def render(self, compress=False): return self.sass_type_name @@ -198,7 +198,7 @@ class Boolean(Value): def __bool__(self): return self.value - def render(self, compress=False, unquote=False): + def render(self, compress=False): if self.value: return 'true' else: @@ -332,6 +332,7 @@ class Number(Value): unit_denom=self.unit_denom * int(exp.value), ) + def __mul__(self, other): if not isinstance(other, Number): return NotImplemented @@ -470,7 +471,7 @@ class Number(Value): def is_unitless(self): return not self.unit_numer and not self.unit_denom - def render(self, compress=False, unquote=False): + def render(self, compress=False): if not self.has_simple_unit: raise ValueError("Can't express compound units in CSS: %r" % (self,)) @@ -604,14 +605,14 @@ class List(Value): def __getitem__(self, key): return self.value[key] - def render(self, compress=False, unquote=False): + def render(self, compress=False): if not self.value: raise ValueError("Can't render empty list as CSS") delim = self.delimiter(compress) return delim.join( - item.render(compress=compress, unquote=unquote) + item.render(compress=compress) for item in self.value ) @@ -847,7 +848,7 @@ class Color(Value): return Color.from_rgb(*new_rgb, alpha=self.alpha) - def render(self, compress=False, unquote=False): + def render(self, compress=False): """Return a rendered representation of the color. If `compress` is true, the shortest possible representation is used; otherwise, named colors are rendered as names and all others are rendered as hex (or @@ -942,8 +943,8 @@ class String(Value): def __hash__(self): return hash(self.value) - def __str__(self, unquote=False): - if self.quotes and not unquote: + def __str__(self): + if self.quotes: return self.quotes + escape(self.value) + self.quotes else: return self.value @@ -983,8 +984,8 @@ class String(Value): return String(self.value * int(other.value), quotes=self.quotes) - def render(self, compress=False, unquote=False): - return self.__str__(unquote) + def render(self, compress=False): + return self.__str__() ### XXX EXPERIMENTAL XXX @@ -1019,7 +1020,7 @@ class Map(Value): def get_by_pos(self, key): return self.pairs[key][1] - def render(self, compress=False, unquote=False): + def render(self, compress=False): raise TypeError("Cannot render map %r as CSS" % (self,)) |