|
12 | 12 | // @returns
|
13 | 13 | @function remove($item, $indicator) {
|
14 | 14 | $i: 1;
|
15 |
| - $item: remove.value($item, '+'); |
16 |
| - @each $value in $item { |
17 |
| - @if type-of($value) == string { |
18 |
| - $item: list.set-nth($item, $i, string.replace(#{$value}, all, $indicator, '')); |
19 |
| - } @else if type-of($value) == list { |
20 |
| - $j: 1; |
21 |
| - @each $v in $value { |
22 |
| - $value: list.set-nth($value, $j, string.replace(#{$v}, all, $indicator, '')); |
23 |
| - $j: $j + 1; |
| 15 | + @if type-of($item) == string { |
| 16 | + @if string.index($item, $indicator) { |
| 17 | + $item: string.slice($item, 2); |
| 18 | + } |
| 19 | + } @else { |
| 20 | + @each $value in $item { |
| 21 | + @if type-of($value) == string { |
| 22 | + $item: list.set-nth($item, $i, string.replace(#{$value}, all, $indicator, '')); |
| 23 | + } @else if type-of($value) == list { |
| 24 | + $j: 1; |
| 25 | + @each $v in $value { |
| 26 | + $value: list.set-nth($value, $j, string.replace(#{$v}, all, $indicator, '')); |
| 27 | + $j: $j + 1; |
| 28 | + } |
| 29 | + |
| 30 | + $item: list.set-nth($item, $i, $value); |
24 | 31 | }
|
25 | 32 |
|
26 |
| - $item: list.set-nth($item, $i, $value); |
| 33 | + $i: $i + 1; |
27 | 34 | }
|
28 |
| - |
29 |
| - $i: $i + 1; |
30 | 35 | }
|
31 | 36 | @return $item;
|
32 | 37 | }
|
| 38 | + |
| 39 | +// Examples. |
| 40 | +// @debug remove(+background, '+'); |
| 41 | +// @debug remove(+bg, '+'); |
| 42 | +// @debug type-of(remove(+bg, '+')); |
0 commit comments