mirror of
https://github.com/less/less.js.git
synced 2026-02-07 05:25:04 -05:00
21 lines
621 B
JavaScript
21 lines
621 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 (!/^(?:https?:\/|file:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
|
|
val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);
|
|
}
|
|
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'));
|