Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,9 @@ protected function compileChild($child, OutputBlock $out)
$this->pushEnv();
$this->env->depth--;

$storeEnv = $this->storeEnv;
$this->storeEnv = $this->env;

if (isset($content)) {
$content->scope = $callingScope;

Expand All @@ -1710,6 +1713,8 @@ protected function compileChild($child, OutputBlock $out)

$this->compileChildrenNoReturn($mixin->children, $out);

$this->storeEnv = $storeEnv;

$this->popEnv();
break;

Expand Down Expand Up @@ -3346,6 +3351,9 @@ protected function callScssFunction($name, $argValues, &$returnValue)

$this->pushEnv();

$storeEnv = $this->storeEnv;
$this->storeEnv = $this->env;

// set the args
if (isset($func->args)) {
$this->applyArguments($func->args, $argValues);
Expand All @@ -3360,6 +3368,8 @@ protected function callScssFunction($name, $argValues, &$returnValue)

$ret = $this->compileChildren($func->children, $tmp);

$this->storeEnv = $storeEnv;

$this->popEnv();

$returnValue = ! isset($ret) ? self::$defaultValue : $ret;
Expand Down
38 changes: 38 additions & 0 deletions tests/inputs/functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,41 @@ $str: 'global';
l4: inspect((a: 1, b: 2));
l5: inspect($value: (a: 1, b: 2));
}

@function contains($list, $values...) {
@each $value in $values {
@if type-of(index($list, $value)) != "number" {
@return false;
}
}

@return true;
}

@function mapping($items) {
$src: ();
$map: (
one: 1px 1px,
two: 2px 2px,
);

@each $key, $values in $map {
@if contains($items, $key) {
$value1: nth($values, 1);
$value2: nth($values, 2);

$src: append($src, $value1 $value2, space);
}
}

@return $src;
}

@mixin test() {
padding: mapping(one two);
}

div {
margin: mapping(one two);
@include test();
}
18 changes: 18 additions & 0 deletions tests/inputs/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,21 @@ div.parameter-name-scope {
.test{
@include test-mixin();
}

@mixin inner($value) {}

@mixin outer($value) {
#{$value} {
content: "#{$value}";
@content;
content: "#{$value}";
}
}

@include outer(div) {
@include inner('break');
@include outer(p) {
@include inner('break');
}
}

4 changes: 4 additions & 0 deletions tests/outputs/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ p {
l3: 5, 6;
l4: (a: 1, b: 2);
l5: (a: 1, b: 2); }

div {
margin: 1px 1px 2px 2px;
padding: 1px 1px 2px 2px; }
7 changes: 7 additions & 0 deletions tests/outputs/mixins.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ div.parameter-name-scope {
@media screen and (min-width:0\0) {
.test {
color: #000; } }

div {
content: "div";
content: "div"; }
div p {
content: "p";
content: "p"; }
4 changes: 4 additions & 0 deletions tests/outputs_numbered/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ p {
l3: 5, 6;
l4: (a: 1, b: 2);
l5: (a: 1, b: 2); }
/* line 165, inputs/functions.scss */
div {
margin: 1px 1px 2px 2px;
padding: 1px 1px 2px 2px; }
8 changes: 8 additions & 0 deletions tests/outputs_numbered/mixins.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,11 @@ div.parameter-name-scope {
@media screen and (min-width:0\0) {
.test {
color: #000; } }
/* line 197, inputs/mixins.scss */
div {
content: "div";
content: "div"; }
/* line 197, inputs/mixins.scss */
div p {
content: "p";
content: "p"; }