From 4cda3620de9e45bac459c4c40343405a4670fb14 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Thu, 13 Dec 2018 00:11:40 +0100 Subject: [PATCH] Add deprecation for hsla with percentage alpha --- src/fn_colors.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/fn_colors.cpp b/src/fn_colors.cpp index ea2e28ff9..f074528dc 100644 --- a/src/fn_colors.cpp +++ b/src/fn_colors.cpp @@ -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) { @@ -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"),