diff --git a/library/Icinga/Less/Call.php b/library/Icinga/Less/Call.php index bb5139d14..0e6074dbe 100644 --- a/library/Icinga/Less/Call.php +++ b/library/Icinga/Less/Call.php @@ -34,7 +34,7 @@ class Call extends Less_Tree_Call } if ($name) { - foreach (array_reverse($env->frames) as $frame) { + foreach ($env->frames as $frame) { if (($v = $frame->variable($name))) { // Variables from the frame stack are always of type LESS Tree Rule $vr = $v->value; diff --git a/library/Icinga/Less/ColorProp.php b/library/Icinga/Less/ColorProp.php index f10115d75..b6fe6d2e2 100644 --- a/library/Icinga/Less/ColorProp.php +++ b/library/Icinga/Less/ColorProp.php @@ -38,7 +38,11 @@ class ColorProp extends Less_Tree_Color $self->color = $color; foreach ($color as $k => $v) { - $self->$k = $v; + if ($k === 'name') { + $self->setName($v); // Removes the @ char from the name + } else { + $self->$k = $v; + } } return $self; @@ -79,6 +83,10 @@ class ColorProp extends Less_Tree_Color */ public function setName($name) { + if ($name[0] === '@') { + $name = substr($name, 1); + } + $this->name = $name; return $this; diff --git a/library/Icinga/Less/ColorPropOrVariable.php b/library/Icinga/Less/ColorPropOrVariable.php index 371cca47f..8920999bb 100644 --- a/library/Icinga/Less/ColorPropOrVariable.php +++ b/library/Icinga/Less/ColorPropOrVariable.php @@ -45,7 +45,12 @@ class ColorPropOrVariable extends Less_Tree // Evaluate variable variable as in Less_Tree_Variable:28. $vv = new Less_Tree_Variable(substr($v->name, 1), $v->index + 1, $v->currentFileInfo); // Overwrite the name so that the variable variable is not evaluated again. - $v->name = '@' . $vv->compile($env)->value; + $result = $vv->compile($env); + if ($result instanceof DeferredColorProp) { + $v->name = $result->name; + } else { + $v->name = '@' . $result->value; + } } $compiled = $v->compile($env); @@ -58,7 +63,7 @@ class ColorPropOrVariable extends Less_Tree if ($compiled instanceof Less_Tree_Color) { return ColorProp::fromColor($compiled) ->setIndex($v->index) - ->setName(substr($v->name, 1)); + ->setName($v->name); } return $compiled; diff --git a/library/Icinga/Less/DeferredColorProp.php b/library/Icinga/Less/DeferredColorProp.php index 7c2468f0b..becb04251 100644 --- a/library/Icinga/Less/DeferredColorProp.php +++ b/library/Icinga/Less/DeferredColorProp.php @@ -5,6 +5,7 @@ namespace Icinga\Less; use Less_Exception_Compiler; use Less_Tree_Call; use Less_Tree_Color; +use Less_Tree_Keyword; use Less_Tree_Value; use Less_Tree_Variable; @@ -89,7 +90,7 @@ class DeferredColorProp extends Less_Tree_Variable $this->evaluating = true; - foreach (array_reverse($env->frames) as $frame) { + foreach ($env->frames as $frame) { if (($v = $frame->variable($this->getRef()->name))) { $rv = $v->value; if ($rv instanceof Less_Tree_Value) { @@ -122,7 +123,7 @@ class DeferredColorProp extends Less_Tree_Variable $css = (new Less_Tree_Call( 'var', [ - new \Less_Tree_Keyword('--' . $this->getName()), + new Less_Tree_Keyword('--' . $this->getName()), $this->getRef() // Each of the references will be generated recursively ], $this->index