mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
added fraction support to round function
This commit is contained in:
committed by
Luke Page
parent
d81ba3bb38
commit
86520e53e8
@@ -179,8 +179,15 @@ tree.functions = {
|
||||
str = str.replace(/%%/g, '%');
|
||||
return new(tree.Quoted)('"' + str + '"', str);
|
||||
},
|
||||
round: function (n) {
|
||||
return this._math('round', n);
|
||||
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" };
|
||||
}
|
||||
},
|
||||
ceil: function (n) {
|
||||
return this._math('ceil', n);
|
||||
|
||||
Reference in New Issue
Block a user