diff options
author | Eevee (Lexy Munroe) <eevee.git@veekun.com> | 2016-06-08 17:38:53 -0700 |
---|---|---|
committer | Eevee (Lexy Munroe) <eevee.git@veekun.com> | 2016-06-08 17:38:53 -0700 |
commit | 905559d199a3db9ab14cff16e6b1fb652e926c30 (patch) | |
tree | 02c81c0e2745eaab3e161d82579bcd00661f7728 | |
parent | 1f3a76655de764cd66f0ddb42b3d99e6020c1dca (diff) | |
download | pyscss-905559d199a3db9ab14cff16e6b1fb652e926c30.tar.gz |
append() should default to spaces. Fixes #335
-rw-r--r-- | scss/extension/core.py | 38 | ||||
-rw-r--r-- | scss/tests/files/bugs/append.css | 5 | ||||
-rw-r--r-- | scss/tests/files/bugs/append.scss | 10 |
3 files changed, 31 insertions, 22 deletions
diff --git a/scss/extension/core.py b/scss/extension/core.py index b939d1c..7b69315 100644 --- a/scss/extension/core.py +++ b/scss/extension/core.py @@ -626,26 +626,6 @@ ns.set_function('floor', 1, Number.wrap_python_function(math.floor)) # ------------------------------------------------------------------------------ # List functions -def __parse_separator(separator, default_from=None): - if separator is None: - separator = 'auto' - separator = String.unquoted(separator).value - - if separator == 'comma': - return True - elif separator == 'space': - return False - elif separator == 'auto': - if not default_from: - return True - elif len(default_from) < 2: - return True - else: - return default_from.use_comma - else: - raise ValueError('Separator must be auto, comma, or space') - - # TODO get the compass bit outta here @ns.declare_alias('-compass-list-size') @ns.declare @@ -729,12 +709,26 @@ def max_(*lst): @ns.declare -def append(lst, val, separator=None): +def append(lst, val, separator=String.unquoted('auto')): + expect_type(separator, String) + ret = [] ret.extend(List.from_maybe(lst)) ret.append(val) - use_comma = __parse_separator(separator, default_from=lst) + separator = separator.value + if separator == 'comma': + use_comma = True + elif separator == 'space': + use_comma = False + elif separator == 'auto': + if len(lst) < 2: + use_comma = False + else: + use_comma = lst.use_comma + else: + raise ValueError('Separator must be auto, comma, or space') + return List(ret, use_comma=use_comma) diff --git a/scss/tests/files/bugs/append.css b/scss/tests/files/bugs/append.css new file mode 100644 index 0000000..c5e87fa --- /dev/null +++ b/scss/tests/files/bugs/append.css @@ -0,0 +1,5 @@ +p { + a: 1; + b: 1 2; + c: 1, 2, 3; +} diff --git a/scss/tests/files/bugs/append.scss b/scss/tests/files/bugs/append.scss new file mode 100644 index 0000000..2b6aff9 --- /dev/null +++ b/scss/tests/files/bugs/append.scss @@ -0,0 +1,10 @@ +// Default when the first list has < 2 elements is space +$a: append((), 1); +$b: append(append((), 1, comma), 2); +$c: append((1, 2), 3); + +p { + a: $a; + b: $b; + c: $c; +} |