summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerman M. Bravo <german.mb@deipi.com>2013-10-06 14:15:16 -0500
committerGerman M. Bravo <german.mb@deipi.com>2013-10-06 14:15:16 -0500
commit7b953669c48598cbf1f45eb558f46746318ac418 (patch)
tree63327b0477633ee00c3ab8e75c8439e4f6024049
parent16e5615d17e079f88ca8766aba70c0fbfe4be335 (diff)
downloadpyscss-7b953669c48598cbf1f45eb558f46746318ac418.tar.gz
Nest fixed (when using '&' in it)
-rw-r--r--scss/functions/compass/helpers.py24
-rw-r--r--scss/tests/files/kronuz/selectors-nest.css3
-rw-r--r--scss/tests/files/kronuz/selectors-nest.scss7
3 files changed, 32 insertions, 2 deletions
diff --git a/scss/functions/compass/helpers.py b/scss/functions/compass/helpers.py
index 6ae8a54..94f4884 100644
--- a/scss/functions/compass/helpers.py
+++ b/scss/functions/compass/helpers.py
@@ -335,9 +335,29 @@ def headers(frm=None, to=None):
@register('nest')
def nest(*arguments):
- ret = [''] # Hackery for initial value
+ if isinstance(arguments[0], List):
+ lst = arguments[0]
+ elif isinstance(arguments[0], String):
+ lst = arguments[0].value.split(',')
+ else:
+ raise TypeError("Expected list or string, got %r" % (arguments[0],))
+
+ ret = []
+ for s in lst:
+ if isinstance(s, String):
+ s = s.value
+ elif isinstance(s, six.string_types):
+ s = s
+ else:
+ raise TypeError("Expected string, got %r" % (s,))
+
+ s = s.strip()
+ if not s:
+ continue
+
+ ret.append(s)
- for arg in arguments:
+ for arg in arguments[1:]:
if isinstance(arg, List):
lst = arg
elif isinstance(arg, String):
diff --git a/scss/tests/files/kronuz/selectors-nest.css b/scss/tests/files/kronuz/selectors-nest.css
new file mode 100644
index 0000000..77654e3
--- /dev/null
+++ b/scss/tests/files/kronuz/selectors-nest.css
@@ -0,0 +1,3 @@
+div.hover a, div:hover a, p.hover a, p:hover a {
+ color: red;
+}
diff --git a/scss/tests/files/kronuz/selectors-nest.scss b/scss/tests/files/kronuz/selectors-nest.scss
new file mode 100644
index 0000000..8580b3a
--- /dev/null
+++ b/scss/tests/files/kronuz/selectors-nest.scss
@@ -0,0 +1,7 @@
+@option style:legacy;
+
+p, div {
+ #{nest('&:hover, &.hover', 'a')} {
+ color: red;
+ }
+}