Skip to content

Commit

Permalink
Better list separator detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Burel committed Jul 28, 2016
1 parent 9647e2f commit d74062d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions _rem.scss
Expand Up @@ -2,12 +2,16 @@ $rem-baseline: 10px !default;
$rem-fallback: true !default;
$rem-px-only: false !default;

// list-separator polyfill by Hugo Giraudel (https://sass-compatibility.github.io/#list_separator_function)
@function rem-separator($list) {
@function rem-separator($list, $separator: false) {
@if $separator == "comma" or $separator == "space" {
@return append($list, null, $separator);
}

@if function-exists("list-separator") == true {
@return list-separator($list);
}

// list-separator polyfill by Hugo Giraudel (https://sass-compatibility.github.io/#list_separator_function)
$test-list: ();
@each $item in $list {
$test-list: append($test-list, $item, space);
Expand All @@ -30,10 +34,10 @@ $rem-px-only: false !default;
} @else if type-of($value) == "number" and unit($value) == "px" and $to == "rem" {
$result: append($result, $value / $rem-baseline + 0rem, $separator);
} @else if type-of($value) == "list" {
$tmp-separator: list-separator($value);
$tmp: rem-convert($to, $value...);
$tmp: append($tmp, null, $tmp-separator);
$result: append($result, $tmp, $separator);
$value-separator: rem-separator($value);
$value: rem-convert($to, $value...);
$value: rem-separator($value, $value-separator);
$result: append($result, $value, $separator);
} @else {
$result: append($result, $value, $separator);
}
Expand Down

0 comments on commit d74062d

Please sign in to comment.