mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
support relative url() paths in the browser
This commit is contained in:
@@ -526,7 +526,7 @@ less.Parser = function Parser(env) {
|
||||
if (! $(')')) throw new(Error)("missing closing ) for url()");
|
||||
|
||||
return new(tree.URL)((value.value || value instanceof tree.Variable)
|
||||
? value : new(tree.Anonymous)(value));
|
||||
? value : new(tree.Anonymous)(value), imports.paths);
|
||||
},
|
||||
|
||||
//
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.URL = function (val) {
|
||||
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('/');
|
||||
}
|
||||
this.value = val;
|
||||
};
|
||||
tree.URL.prototype = {
|
||||
|
||||
Reference in New Issue
Block a user