support variables in url()

This commit is contained in:
cloudhead
2010-07-04 10:45:55 +02:00
parent 75e7f801fe
commit c68867c8e2
4 changed files with 9 additions and 3 deletions

View File

@@ -519,10 +519,11 @@ less.Parser = function Parser(env) {
var value;
if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
value = $(this.entities.quoted) || $(/^[-\w%@$\/.&=:;#+?]+/);
value = $(this.entities.quoted) || $(this.entities.variable) || $(/^[-\w%@$\/.&=:;#+?]+/);
if (! $(')')) throw new(Error)("missing closing ) for url()");
return new(tree.URL)(value.value ? value : new(tree.Anonymous)(value));
return new(tree.URL)((value.value || value instanceof tree.Variable)
? value : new(tree.Anonymous)(value));
},
//

View File

@@ -7,7 +7,10 @@ tree.URL.prototype = {
toCSS: function () {
return "url(" + this.value.toCSS() + ")";
},
eval: function () { return this }
eval: function (ctx) {
this.value = this.value.eval(ctx);
return this;
}
};
})(require('less/tree'));