Check for deferred color prop when defining variable variable & some fixlets for naming issue
This commit is contained in:
parent
a2932bd5ce
commit
5a04480245
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue