Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: throw on weitht passed to CSS3 invert() #2950

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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