url() parsing
This commit is contained in:
parent
6d022858be
commit
8a7747d15b
@ -8,7 +8,8 @@ process.mixin(less, require('less/parser'));
|
||||
|
||||
['color', 'directive', 'operation', 'dimension',
|
||||
'keyword', 'variable', 'ruleset', 'element',
|
||||
'selector', 'quoted', 'expression', 'rule', 'call'
|
||||
'selector', 'quoted', 'expression', 'rule',
|
||||
'call', 'url'
|
||||
].forEach(function (n) {
|
||||
process.mixin(less.parser, require(path.join('less', 'node', n)));
|
||||
});
|
||||
|
9
lib/less/node/url.js
Normal file
9
lib/less/node/url.js
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
node.URL = function URL(val) {
|
||||
this.value = val;
|
||||
};
|
||||
node.URL.prototype = {
|
||||
toCSS: function () {
|
||||
return "url(" + this.value.toCSS ? this.value.toCSS() : this.value + ")";
|
||||
}
|
||||
};
|
@ -206,6 +206,13 @@ less.parser = {
|
||||
$(this.entities.string);
|
||||
},
|
||||
url: function url() {
|
||||
var value;
|
||||
|
||||
if (! $(/url\(/g)) return;
|
||||
value = $(this.entities.string) || $(/[-a-zA-Z0-9_%@$\/.&=:;#+?]+/g);
|
||||
if (! $(')')) throw new(Error)("missing closing ) for url()");
|
||||
|
||||
return new(node.URL)(value);
|
||||
},
|
||||
font: function font() {
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user