Skip to content

Commit

Permalink
Work-around for fatal error when using overloaded functions with vari…
Browse files Browse the repository at this point in the history
…able parameters. #48
  • Loading branch information
JohnAlbin committed Oct 16, 2016
1 parent 6f1ec27 commit 0e8f849
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sass/chroma/_internals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@

// _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().
// LibSass incorrectly throws an error when using the variable argument
// indicator, ..., with an overloaded function; e.g. rgba(). To work-around this
// bug, we call rgba() with direct parameters.
//
// @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 rgba(nth($parameters, 1), nth($parameters, 2));
}
@return call($function, $parameters...);
}
8 changes: 8 additions & 0 deletions test/fixtures/internals/_safe-call/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import 'chroma';

$function: rgba;
$parameters: #fff, .5;

.test {
color: _safe-call($function, $parameters...);
}
2 changes: 2 additions & 0 deletions test/fixtures/internals/_safe-call/output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.test {
color: rgba(255, 255, 255, 0.5); }
6 changes: 6 additions & 0 deletions test/test_internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,10 @@ describe('@import "chroma/internals";', function() {
return sassyTest.renderFixture('_is-keyword-string');
});
});

describe('@function _safe-call()', function() {
it('should call an overloaded function without error with LibSass before libsass#2205', function() {
return sassyTest.renderFixture('_safe-call');
});
});
});

0 comments on commit 0e8f849

Please # to comment.