Skip to content

Commit

Permalink
fixed bug with reducing functions
Browse files Browse the repository at this point in the history
function values without a list argument type were throwing errors
when being reduced

this showed up when writing a lib_url method to overwrite the
default behavior of css url()
  • Loading branch information
leafo committed Mar 12, 2011
1 parent 0f51228 commit c0c49a4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lessc.inc.php
Expand Up @@ -1128,18 +1128,23 @@ function reduce($var, $defaultValue = array('number', 0)) {
$color = $this->funcToColor($var);
if ($color) $var = $color;
else {
$f = array($this, 'lib_'.$var[1]);
list($_, $name, $args) = $var;
$f = array($this, 'lib_'.$name);
if (is_callable($f)) {
list($_, $delim, $items) = $var[2];
$var = call_user_func($f, $this->compressList($items, $delim));
if ($args[0] == 'list')
$args = $this->compressList($args[2], $args[1]);

$var = call_user_func($f, $args);

// convet to a typed value if the result is a php primitive
if (is_numeric($var)) $var = array('number', $var);
elseif (!is_array($var)) $var = array('keyword', $var);
} else {
// plain function, reduce args
$var[2] = $this->reduce($var[2]);
}
}
break; // no where to go after a function
break; // done reducing after a function
} elseif ($var[0] == 'negative') {
$value = $this->reduce($var[1]);
if (is_numeric($value[1])) {
Expand Down

0 comments on commit c0c49a4

Please sign in to comment.