Skip to content

Commit

Permalink
fix: throw on weitht passed to CSS3 invert()
Browse files Browse the repository at this point in the history
  • Loading branch information
nschonni committed Jul 18, 2019
1 parent ac338df commit d972c50
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/fn_colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,16 @@ namespace Sass {
{
// CSS3 filter function overload: pass literal through directly
Number* amount = Cast<Number>(env["$color"]);
double weight = DARG_U_PRCT("$weight");
if (amount) {
// TODO: does not throw on 100% manually passed as value
if (weight < 100.0) {
error("Only one argument may be passed to the plain-CSS invert() function.", pstate, traces);
}
return SASS_MEMORY_NEW(String_Quoted, pstate, "invert(" + amount->to_string(ctx.c_options) + ")");
}

Color* col = ARG("$color", Color);
double weight = DARG_U_PRCT("$weight");
Color_RGBA_Obj inv = col->copyAsRGBA();
inv->r(clip(255.0 - inv->r(), 0.0, 255.0));
inv->g(clip(255.0 - inv->g(), 0.0, 255.0));
Expand Down

0 comments on commit d972c50

Please sign in to comment.