dotless/dotless — Issue #143: Comparison between a number and number in pixels fails when using guard expression
Author: darlesson
Created: 2012-02-29 22:42:05+00:00
State: open

In the example below I am using guard expression to make sure the border-radius value is not negative. If it is it should return the values as 0px.

```css
.border-radius (@radius: 0px) when (@radius >= 0) {
-webkit-border-radius: @arguments;
-moz-border-radius: @arguments;
border-radius: @arguments;
-moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;
}

.border-radius (@radius: 0px) when (@radius < 0) {
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
-moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;
}
```

The application where I am working I have a variable with the maximum border radius. In different classes this value is decreased making possible to change the theme round-corners to less round or not round at all.

```css
@maxBorderRadius: 6px;

.button{
.border-radius(@maxBorderRadius - 2);
}

.popup{
.border-radius(@maxBorderRadius);
> .popup-wrap{
.border-radius(@maxBorderRadius - 1);
}
}
```

If I change the variable @maxBorderRadius value to number it works. If I keep the px unit it always returns the second .border-radius() method.

Thanks,