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

Support var() in rbga short-hand syntax #2564

Merged
merged 1 commit into from
Feb 20, 2018
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
17 changes: 14 additions & 3 deletions src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ namespace Sass {

inline bool special_number(String_Constant_Ptr s) {
if (s) {
std::string calc("calc");
std::string var("var");
std::string calc("calc(");
std::string var("var(");
std::string ss(s->value());
return std::equal(calc.begin(), calc.end(), ss.begin()) ||
std::equal(var.begin(), var.end(), ss.begin());
Expand Down Expand Up @@ -386,6 +386,17 @@ namespace Sass {
Signature rgba_2_sig = "rgba($color, $alpha)";
BUILT_IN(rgba_2)
{
if (
special_number(Cast<String_Constant>(env["$color"]))
) {
return SASS_MEMORY_NEW(String_Constant, pstate, "rgba("
+ env["$color"]->to_string()
+ ", "
+ env["$alpha"]->to_string()
+ ")"
);
}

Color_Ptr c_arg = ARG("$color", Color);

if (
Expand Down Expand Up @@ -1738,7 +1749,7 @@ namespace Sass {

Signature unit_sig = "unit($number)";
BUILT_IN(unit)
{
{
Number_Obj arg = ARGN("$number");
std::string str(quote(arg->unit(), '"'));
return SASS_MEMORY_NEW(String_Quoted, pstate, str);
Expand Down