Skip to content

Commit 4cda362

Browse files
committed
Add deprecation for hsla with percentage alpha
1 parent aa9852b commit 4cda362

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/fn_colors.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ namespace Sass {
1717
starts_with(str, "var(");
1818
}
1919

20+
void hsla_alpha_percent_deprecation(const ParserState& pstate, const std::string val)
21+
{
22+
23+
std::string msg("Passing a percentage as the alpha value to hsla() will be interpreted");
24+
std::string tail("differently in future versions of Sass. For now, use " + val + " instead.");
25+
26+
deprecated(msg, tail, false, pstate);
27+
28+
}
29+
2030
Signature rgb_sig = "rgb($red, $green, $blue)";
2131
BUILT_IN(rgb)
2232
{
@@ -211,6 +221,15 @@ namespace Sass {
211221
);
212222
}
213223

224+
Number_Ptr alpha = ARG("$alpha", Number);
225+
if (alpha && alpha->unit() == "%") {
226+
Number_Obj val = SASS_MEMORY_COPY(alpha);
227+
val->numerators.clear(); // convert
228+
val->value(val->value() / 100.0);
229+
std::string nr(val->to_string(ctx.c_options));
230+
hsla_alpha_percent_deprecation(pstate, nr);
231+
}
232+
214233
return SASS_MEMORY_NEW(Color_HSLA,
215234
pstate,
216235
ARGVAL("$hue"),

0 commit comments

Comments
 (0)