From 7b953669c48598cbf1f45eb558f46746318ac418 Mon Sep 17 00:00:00 2001 From: "German M. Bravo" Date: Sun, 6 Oct 2013 14:15:16 -0500 Subject: Nest fixed (when using '&' in it) --- scss/functions/compass/helpers.py | 24 ++++++++++++++++++++++-- scss/tests/files/kronuz/selectors-nest.css | 3 +++ scss/tests/files/kronuz/selectors-nest.scss | 7 +++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 scss/tests/files/kronuz/selectors-nest.css create mode 100644 scss/tests/files/kronuz/selectors-nest.scss 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; + } +} -- cgit v1.2.1