diff --git a/lib/less/functions.js b/lib/less/functions.js index 80fea56e..ea7c2d16 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -209,6 +209,9 @@ tree.functions = { str = str.replace(/%%/g, '%'); return new(tree.Quoted)('"' + str + '"', str); }, + unit: function (val, unit) { + return new(tree.Dimension)(val.value, unit ? unit.toCSS() : ""); + }, round: function (n, f) { var fraction = typeof(f) === "undefined" ? 0 : f.value; if (n instanceof tree.Dimension) { diff --git a/test/css/functions.css b/test/css/functions.css index c0c51e84..0b80cfe7 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -42,6 +42,8 @@ format-multiple: "hello earth 2"; format-url-encode: "red is %23ff0000"; eformat: rgb(32, 128, 64); + unitless: 12; + unit: 14em; hue: 98; saturation: 12%; lightness: 95%; diff --git a/test/less/functions.less b/test/less/functions.less index 274ce49c..41244fbf 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -46,6 +46,9 @@ format-multiple: %("hello %s %d", "earth", 2); format-url-encode: %('red is %A', #ff0000); eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64)); + + unitless: unit(12px); + unit: unit(13px + 1px, em); hue: hue(hsl(98, 12%, 95%)); saturation: saturation(hsl(98, 12%, 95%));