support relative url() paths in the browser

This commit is contained in:
cloudhead
2010-07-25 16:42:19 -04:00
parent 4399c9c965
commit 326e863bbc
2 changed files with 8 additions and 2 deletions

View File

@@ -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);
},
//

View File

@@ -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 = {