Skip to content

Commit 1bb3dc1

Browse files
committed
Fix trailing space when parent selector is the last part of the selector.
''' .foo { .bar & { &:hover { color: orange; } } } ''' now outputs ''' .bar .foo:hover { color: orange; } '''
1 parent 1857b7c commit 1bb3dc1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/less/tree/element.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ tree.Element.prototype.eval = function (env) {
1919
this.index);
2020
};
2121
tree.Element.prototype.toCSS = function (env) {
22-
return this.combinator.toCSS(env || {}) + (this.value.toCSS ? this.value.toCSS(env) : this.value);
22+
var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
23+
if (value == '' && this.combinator.value.charAt(0) == '&') {
24+
return '';
25+
} else {
26+
return this.combinator.toCSS(env || {}) + value;
27+
}
2328
};
2429

2530
tree.Combinator = function (value) {

0 commit comments

Comments
 (0)