mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
getting combinators to output properly. some little hacks, but it beats having a white-space sensitive grammar
This commit is contained in:
@@ -10,16 +10,21 @@ tree.Element.prototype.toCSS = function () {
|
||||
};
|
||||
|
||||
tree.Combinator = function Combinator(value) {
|
||||
this.value = value ? value.trim() : "";
|
||||
if (value === ' ') {
|
||||
this.value = ' ';
|
||||
} else {
|
||||
this.value = value ? value.trim() : "";
|
||||
}
|
||||
};
|
||||
tree.Combinator.prototype.toCSS = function () {
|
||||
switch (this.value) {
|
||||
case '' : return '';
|
||||
case ' ' : return ' ';
|
||||
case '&' : return '';
|
||||
case ':' : return ' :';
|
||||
case '::': return '::';
|
||||
case '+' : return ' + ';
|
||||
case '~' : return ' ~ ';
|
||||
case '>' : return ' > ';
|
||||
default : return ' ' + this.value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -86,7 +86,9 @@ tree.Ruleset.prototype = {
|
||||
} else {
|
||||
if (rules.length > 0) {
|
||||
selector = paths.map(function (p) {
|
||||
return new(tree.Selector)(p).toCSS().trim();
|
||||
return p.map(function (s) {
|
||||
return s.toCSS();
|
||||
}).join('').trim();
|
||||
}).join(paths.length > 3 ? ',\n' : ', ');
|
||||
css.push(selector, " {\n " + rules.join('\n ') + "\n}\n");
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ less.parser = {
|
||||
if (match = $(/[+>~]/g) || $('&') || $(/::/g)) {
|
||||
return new(tree.Combinator)(match);
|
||||
} else {
|
||||
return new(tree.Combinator);
|
||||
return new(tree.Combinator)(input[i - 1] === " " ? " " : null);
|
||||
}
|
||||
},
|
||||
selector: function () {
|
||||
|
||||
Reference in New Issue
Block a user