create an empty Combinator if none was specified. Refactored Combinator generation, and added + ~ ::

This commit is contained in:
cloudhead 2010-02-28 12:49:08 -05:00
parent adb2fd2864
commit f0c00ab2b4
2 changed files with 7 additions and 3 deletions

View File

@ -4,17 +4,19 @@ node.Element = function Element(combinator, value) {
this.value = value.trim();
};
node.Element.prototype.toCSS = function () {
var css = (this.combinator ? this.combinator.toCSS() : ' ') + this.value;
return css;
return this.combinator.toCSS() + this.value;
};
node.Combinator = function Combinator(value) {
this.value = value.trim();
this.value = value ? value.trim() : "";
};
node.Combinator.prototype.toCSS = function () {
switch (this.value) {
case '&': return "";
case ':': return ' :';
case '::': return '::';
case '+': return ' + ';
case '~': return ' ~ ';
case '>': return ' > ';
default: return ' ' + this.value;
}

View File

@ -331,6 +331,8 @@ less.parser = {
var match;
if (match = $(/[+>~]/g) || $('&') || $(/::/g)) {
return new(node.Combinator)(match);
} else {
return new(node.Combinator);
}
},
selector: function selector() {