mirror of
https://github.com/less/less.js.git
synced 2026-01-22 13:48:03 -05:00
do not divide by 100 when doing maths and keeping the %. Fixes #1069
This commit is contained in:
@@ -214,25 +214,19 @@ tree.functions = {
|
||||
},
|
||||
round: function (n, f) {
|
||||
var fraction = typeof(f) === "undefined" ? 0 : f.value;
|
||||
if (n instanceof tree.Dimension) {
|
||||
return new(tree.Dimension)(number(n).toFixed(fraction), n.unit);
|
||||
} else if (typeof(n) === 'number') {
|
||||
return n.toFixed(fraction);
|
||||
} else {
|
||||
throw { type: "Argument", message: "argument must be a number" };
|
||||
}
|
||||
return this._math(function(num) { return num.toFixed(fraction); }, n);
|
||||
},
|
||||
ceil: function (n) {
|
||||
return this._math('ceil', n);
|
||||
return this._math(Math.ceil, n);
|
||||
},
|
||||
floor: function (n) {
|
||||
return this._math('floor', n);
|
||||
return this._math(Math.floor, n);
|
||||
},
|
||||
_math: function (fn, n) {
|
||||
if (n instanceof tree.Dimension) {
|
||||
return new(tree.Dimension)(Math[fn](number(n)), n.unit);
|
||||
return new(tree.Dimension)(fn(parseFloat(n.value)), n.unit);
|
||||
} else if (typeof(n) === 'number') {
|
||||
return Math[fn](n);
|
||||
return fn(n);
|
||||
} else {
|
||||
throw { type: "Argument", message: "argument must be a number" };
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@
|
||||
rounded-two: 10.67;
|
||||
roundedpx: 3px;
|
||||
roundedpx-three: 3.333px;
|
||||
rounded-percentage: 10%;
|
||||
ceil: 11px;
|
||||
floor: 12px;
|
||||
percentage: 20%;
|
||||
color: #ff0011;
|
||||
tint: #898989;
|
||||
|
||||
@@ -60,6 +60,9 @@
|
||||
rounded-two: round(@r/3, 2);
|
||||
roundedpx: round(10px / 3);
|
||||
roundedpx-three: round(10px / 3, 3);
|
||||
rounded-percentage: round(10.2%);
|
||||
ceil: ceil(10.1px);
|
||||
floor: floor(12.9px);
|
||||
percentage: percentage(10px / 50);
|
||||
color: color("#ff0011");
|
||||
tint: tint(#777777, 13);
|
||||
|
||||
Reference in New Issue
Block a user