mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04: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" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user