Sha256: 4ae329deb07d0b88410c1875e3790eb82980130631fbd7e360c0ece74ed793c2

Contents?: true

Size: 901 Bytes

Versions: 8

Compression:

Stored size: 901 Bytes

Contents

(function (tree) {

//
// A number with a unit
//
tree.Dimension = function (value, unit) {
    this.value = parseFloat(value);
    this.unit = unit || null;
};

tree.Dimension.prototype = {
    eval: function () { return this },
    toColor: function () {
        return new(tree.Color)([this.value, this.value, this.value]);
    },
    toCSS: function () {
        var css = this.value + this.unit;
        return css;
    },

    // In an operation between two Dimensions,
    // we default to the first Dimension's unit,
    // so `1px + 2em` will yield `3px`.
    // In the future, we could implement some unit
    // conversions such that `100cm + 10mm` would yield
    // `101cm`.
    operate: function (op, other) {
        return new(tree.Dimension)
                  (tree.operate(op, this.value, other.value),
                  this.unit || other.unit);
    }
};

})(require('less/tree'));

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
less-2.0.7 lib/less/js/lib/less/tree/dimension.js
less-2.0.6 lib/less/js/lib/less/tree/dimension.js
less-2.0.5 lib/less/js/lib/less/tree/dimension.js
less-2.0.4 lib/less/js/lib/less/tree/dimension.js
less-2.0.3 lib/less/js/lib/less/tree/dimension.js
less-2.0.2 lib/less/js/lib/less/tree/dimension.js
less-2.0.1 lib/less/js/lib/less/tree/dimension.js
less-2.0.0 lib/less/js/lib/less/tree/dimension.js