Skip to content

Commit 7140eee

Browse files
committed
fixed negation bug leafo#197
1 parent 8082c4d commit 7140eee

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

lessc.inc.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,20 @@ function value(&$value) {
462462

463463
// see if there is a negation
464464
$s = $this->seek();
465-
if ($this->literal('-', false) && $this->variable($var)) {
466-
$value = array('negative', array('variable', $var));
467-
return true;
465+
if ($this->literal('-', false)) {
466+
$value = null;
467+
if ($this->variable($var)) {
468+
$value = array('variable', $var);
469+
} elseif ($this->buffer{$this->count} == "(" && $this->expression($exp)) {
470+
$value = $exp;
471+
} else {
472+
$this->seek($s);
473+
}
474+
475+
if (!is_null($value)) {
476+
$value = array('negative', $value);
477+
return true;
478+
}
468479
} else {
469480
$this->seek($s);
470481
}
@@ -795,7 +806,7 @@ function tag(&$tag, $simple = false) {
795806
function func(&$func) {
796807
$s = $this->seek();
797808

798-
if ($this->match('(%|[\w\-_][\w\-_:\.]*)', $m) && $this->literal('(')) {
809+
if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) {
799810
$fname = $m[1];
800811

801812
$s_pre_args = $this->seek();

tests/inputs/math.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@
6161
}
6262

6363

64+
.negation {
65+
hello: -(1px);
66+
hello: 0-(1px);
67+
68+
@something: 10;
69+
hello: -@something;
70+
}
71+
72+
6473
// and now here are the tests
6574

6675
.test {

tests/outputs/math.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
mul:50;
2626
}
2727
.keyword-names { height:"hello" 25; }
28+
.negation {
29+
hello:-1px;
30+
hello:-1px;
31+
hello:-10;
32+
}
2833
.test {
2934
single:5;
3035
single:10;

0 commit comments

Comments
 (0)