Skip to content

Commit

Permalink
Merge pull request #610 from stof/support_empty_var
Browse files Browse the repository at this point in the history
Add support for empty fallback in var()
  • Loading branch information
stof committed Aug 29, 2022
2 parents 06d5650 + 049d084 commit c0f0f64
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2804,6 +2804,10 @@ protected function func($name, &$func)
$this->argValues($args) &&
$this->matchChar(')')
) {
if ($name === 'var' && \count($args) === 2 && $args[1][0] === Type::T_NULL) {
$args[1] = [null, [Type::T_STRING, '', [' ']], false];
}

$func = [Type::T_FUNCTION_CALL, $name, $args];

return true;
Expand Down
2 changes: 2 additions & 0 deletions tests/inputs/empty_fallback_var.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// adaptation of css/plain/functions/empty_fallback_var from sass-spec as we don't match the output exactly (but CSS is equivalent)
@import "empty_fallback_var_imports/plain";
1 change: 1 addition & 0 deletions tests/inputs/empty_fallback_var_imports/plain.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a {b: var(--c, )}
3 changes: 3 additions & 0 deletions tests/outputs/empty_fallback_var.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a {
b: var(--c, );
}

0 comments on commit c0f0f64

Please sign in to comment.