Skip to content

Commit

Permalink
Add deprecation for hsla with percentage alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Dec 13, 2018
1 parent aa9852b commit 4cda362
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/fn_colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ namespace Sass {
starts_with(str, "var(");
}

void hsla_alpha_percent_deprecation(const ParserState& pstate, const std::string val)
{

std::string msg("Passing a percentage as the alpha value to hsla() will be interpreted");
std::string tail("differently in future versions of Sass. For now, use " + val + " instead.");

deprecated(msg, tail, false, pstate);

}

Signature rgb_sig = "rgb($red, $green, $blue)";
BUILT_IN(rgb)
{
Expand Down Expand Up @@ -211,6 +221,15 @@ namespace Sass {
);
}

Number_Ptr alpha = ARG("$alpha", Number);
if (alpha && alpha->unit() == "%") {
Number_Obj val = SASS_MEMORY_COPY(alpha);
val->numerators.clear(); // convert
val->value(val->value() / 100.0);
std::string nr(val->to_string(ctx.c_options));
hsla_alpha_percent_deprecation(pstate, nr);
}

return SASS_MEMORY_NEW(Color_HSLA,
pstate,
ARGVAL("$hue"),
Expand Down

0 comments on commit 4cda362

Please sign in to comment.