SomMeri / less4j

Less language is an extension of css and less4j compiles it into regular css. Less adds several dynamic features into css: variables, expressions, nested rules, and so on. Less was designed to be compatible with css and any correct css file is also correct less file.
145 stars 47 forks source link

Mixin guard evaluation inconsistency between Node LESS and LESS4J #340

Open twhoff opened 8 years ago

twhoff commented 8 years ago

I'm running into an issue where I can't detect when a value has been set as just 0 (no units). The code I am trying to use looks like this:

.test-1 {
    .test(0);
}
.test-2 {
    .test(0em);
}
.test-3 {
    .test(0px);
}
.test(@val) when (@val = ~'0') {
    okay: yes;
}

In Node LESS, this compiles to:

.test-1 {
  okay: yes;
}

However, in LESS4J it doesn't generate any output (i.e. no guard evaluated to true).

SomMeri commented 8 years ago

Thank you, it is a bug.

Workaround:

.test(@val) when ((@val = 0) and (get-unit(@val) = ~"" )) {
    okay: yes get-unit(@val);
}