Sha256: 1c922b7f66089bd26153b87d6bd51d115fc0c3fc7331564284e7cf577955c49a

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

(function (tree) {

tree.URL = function (val, rootpath) {
    this.value = val;
    this.rootpath = rootpath;
};
tree.URL.prototype = {
    toCSS: function () {
        return "url(" + this.value.toCSS() + ")";
    },
    eval: function (ctx) {
        var val = this.value.eval(ctx), rootpath;

        // Add the base path if the URL is relative
        if (typeof val.value === "string" && !/^(?:[a-z-]+:|\/)/.test(val.value)) {
            rootpath = this.rootpath;
            if (!val.quote) {
                rootpath = rootpath.replace(/[\(\)'"\s]/g, function(match) { return "\\"+match; });
            }
            val.value = rootpath + val.value;
        }

        return new(tree.URL)(val, this.rootpath);
    }
};

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
less-2.3.3 lib/less/js/lib/less/tree/url.js
less-2.3.2 lib/less/js/lib/less/tree/url.js
less-2.3.1 lib/less/js/lib/less/tree/url.js