Skip to content

Commit

Permalink
Work-around for fatal error when using overloaded functions with call…
Browse files Browse the repository at this point in the history
…(). #48
  • Loading branch information
JohnAlbin committed Oct 13, 2016
1 parent dd90d1b commit 6fc3a8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sass/chroma/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ $chroma: _chroma-init();
$function: map-get(nth($chain, $i), 'function');
$parameters: map-get(nth($chain, $i), 'parameters');
$parameters: set-nth($parameters, 1, $value);
$value: call($function, $parameters...);
$value: _safe-call($function, $parameters...);
}
}
@return $value;
Expand Down Expand Up @@ -382,7 +382,7 @@ $chroma: _chroma-init();
// If the value given is a color, just add it.
@if type-of($color-value) == 'color' and not (_is-old-libsass() and _is-keyword-string($color-value)) {
@if $color-function {
$color-value: call($color-function, $color-parameters...);
$color-value: _safe-call($color-function, $color-parameters...);
}
$chroma: _chroma-add-name($scheme, $color-name,
$value : $color-value,
Expand All @@ -405,7 +405,7 @@ $chroma: _chroma-init();
$new-value: map-get($referenced-color, 'value');
@if $color-function {
$color-parameters: set-nth($color-parameters, 1, $new-value);
$new-value: call($color-function, $color-parameters...);
$new-value: _safe-call($color-function, $color-parameters...);
}
$chroma: _chroma-add-name($scheme, $color-name,
$value : $new-value,
Expand Down
16 changes: 16 additions & 0 deletions sass/chroma/_internals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,19 @@
@function _is-keyword-string($name) {
@return if(map-has-key($_chroma-css4-color-keywords-in-strings, $name), true, false);
}

// _safe-call()
//
// LibSass incorrectly throws an error when using call() with an overloaded
// function; e.g. rgba(). To work-around this bug, we call rgba() directly
// instead of with call().
//
// @TODO: Remove when the fix for https://github.com/sass/libsass/issues/2205 is released.
//
// Style guide: internals._safe-call
@function _safe-call($function, $parameters...) {
@if $function == rgba {
@return rgba($parameters...);
}
@return call($function, $parameters...);
}

0 comments on commit 6fc3a8f

Please # to comment.