Skip to content

Commit 373859c

Browse files
committed
Support var() in rbga short-hand syntax
Fixes #2561 Spec sass/sass-spec#1213
1 parent 343898b commit 373859c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/functions.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ namespace Sass {
320320

321321
inline bool special_number(String_Constant_Ptr s) {
322322
if (s) {
323-
std::string calc("calc");
324-
std::string var("var");
323+
std::string calc("calc(");
324+
std::string var("var(");
325325
std::string ss(s->value());
326326
return std::equal(calc.begin(), calc.end(), ss.begin()) ||
327327
std::equal(var.begin(), var.end(), ss.begin());
@@ -386,6 +386,17 @@ namespace Sass {
386386
Signature rgba_2_sig = "rgba($color, $alpha)";
387387
BUILT_IN(rgba_2)
388388
{
389+
if (
390+
special_number(Cast<String_Constant>(env["$color"]))
391+
) {
392+
return SASS_MEMORY_NEW(String_Constant, pstate, "rgba("
393+
+ env["$color"]->to_string()
394+
+ ", "
395+
+ env["$alpha"]->to_string()
396+
+ ")"
397+
);
398+
}
399+
389400
Color_Ptr c_arg = ARG("$color", Color);
390401

391402
if (
@@ -1738,7 +1749,7 @@ namespace Sass {
17381749

17391750
Signature unit_sig = "unit($number)";
17401751
BUILT_IN(unit)
1741-
{
1752+
{
17421753
Number_Obj arg = ARGN("$number");
17431754
std::string str(quote(arg->unit(), '"'));
17441755
return SASS_MEMORY_NEW(String_Quoted, pstate, str);

0 commit comments

Comments
 (0)