Skip to content

Commit 7d01c0c

Browse files
committed
mixins carry their scope around
1 parent f238f0f commit 7d01c0c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lessc.inc.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,13 +974,15 @@ function compileBlock($block, $parent_tags = null) {
974974
$tags = $this->multiplyTags($parent_tags, $block->tags);
975975
}
976976

977-
$this->pushEnv();
977+
$env = $this->pushEnv();
978978
$lines = array();
979979
$blocks = array();
980980
foreach ($block->props as $prop) {
981981
$this->compileProp($prop, $block, $tags, $lines, $blocks);
982982
}
983983

984+
$block->scope = $env;
985+
984986
$this->pop();
985987

986988
$nl = $isRoot ? "\n".$indent :
@@ -1028,7 +1030,6 @@ function compileBlock($block, $parent_tags = null) {
10281030
return ob_get_clean();
10291031
}
10301032

1031-
10321033
// find the fully qualified tags for a block and its parent's tags
10331034
function multiplyTags($parents, $current) {
10341035
if ($parents == null) return $current;
@@ -1221,6 +1222,12 @@ function compileProp($prop, $block, $tags, &$_lines, &$_blocks) {
12211222
}
12221223

12231224
foreach ($mixins as $mixin) {
1225+
$old_scope = null;
1226+
if (isset($mixin->parent->scope)) {
1227+
$old_scope = $this->env;
1228+
$this->env = $mixin->parent->scope;
1229+
}
1230+
12241231
$have_args = false;
12251232
if (isset($mixin->args)) {
12261233
$have_args = true;
@@ -1238,6 +1245,10 @@ function compileProp($prop, $block, $tags, &$_lines, &$_blocks) {
12381245
$mixin->parent = $old_parent;
12391246

12401247
if ($have_args) $this->pop();
1248+
1249+
if ($old_scope) {
1250+
$this->env = $old_scope;
1251+
}
12411252
}
12421253

12431254
break;

0 commit comments

Comments
 (0)