mirror of
https://github.com/less/less.js.git
synced 2026-02-09 14:35:44 -05:00
It is up to the parser and compiler to rewrite them when those files are imported by another LESS file. - Modified and added test cases for import and import-once rules - Fixed difference between client side and server side handling of relative urls - Added a -rootpath option to lessc to specify another base path for the url rewriting. By default, rootpath=''
24 lines
568 B
JavaScript
24 lines
568 B
JavaScript
(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);
|
|
|
|
// Add the base path if the URL is relative
|
|
if (typeof val.value === "string" && !/^(?:[a-z-]+:|\/)/.test(val.value)) {
|
|
val.value = this.rootpath + val.value;
|
|
}
|
|
|
|
return new(tree.URL)(val, this.rootpath);
|
|
}
|
|
};
|
|
|
|
})(require('../tree'));
|