4 // A number with a unit
6 tree.Dimension = function (value, unit) {
7 this.value = parseFloat(value);
8 this.unit = unit || null;
11 tree.Dimension.prototype = {
12 eval: function () { return this },
13 toColor: function () {
14 return new(tree.Color)([this.value, this.value, this.value]);
17 var css = this.value + this.unit;
21 // In an operation between two Dimensions,
22 // we default to the first Dimension's unit,
23 // so `1px + 2em` will yield `3px`.
24 // In the future, we could implement some unit
25 // conversions such that `100cm + 10mm` would yield
27 operate: function (op, other) {
28 return new(tree.Dimension)
29 (tree.operate(op, this.value, other.value),
30 this.unit || other.unit);
34 })(require('less/tree'));