Files
less.js/lib/less/tree/url.js
2010-07-25 17:01:27 -04:00

21 lines
588 B
JavaScript

(function (tree) {
tree.URL = function (val, paths) {
// Add the base path if the URL is relative and we are in the browser
if (!/^(?:http:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
val.value = [paths[0], val.value].join('/').replace('//', '/');
}
this.value = val;
this.paths = paths;
};
tree.URL.prototype = {
toCSS: function () {
return "url(" + this.value.toCSS() + ")";
},
eval: function (ctx) {
return new(tree.URL)(this.value.eval(ctx), this.paths);
}
};
})(require('less/tree'));