Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1973 #2182

Merged
merged 1 commit into from
Sep 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/less/tree/element.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Node = require("./node.js"),
Paren = require("./paren.js"),
Combinator = require("./combinator.js");

var Element = function (combinator, value, index, currentFileInfo) {
Expand Down Expand Up @@ -34,11 +35,19 @@ Element.prototype.genCSS = function (env, output) {
output.add(this.toCSS(env), this.currentFileInfo, this.index);
};
Element.prototype.toCSS = function (env) {
var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
env = env || {};
var value = this.value, firstSelector = env.firstSelector;
if (value instanceof Paren) {
// selector in parens should not be affected by outer selector
// flags (breaks only interpolated selectors - see #1973)
env.firstSelector = true;
}
value = value.toCSS ? value.toCSS(env) : value;
env.firstSelector = firstSelector;
if (value === '' && this.combinator.value.charAt(0) === '&') {
return '';
} else {
return this.combinator.toCSS(env || {}) + value;
return this.combinator.toCSS(env) + value;
}
};
module.exports = Element;
3 changes: 3 additions & 0 deletions test/css/selectors.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ p a span {
:nth-child(3) {
selector: interpolated;
}
.test:nth-child(3) {
selector: interpolated;
}
.test:nth-child(odd):not(:nth-child(3)) {
color: #ff0000;
}
Expand Down
3 changes: 3 additions & 0 deletions test/less/selectors.less
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ a {
selector: interpolated;
}
.test {
&:nth-child(@{num}) {
selector: interpolated;
}
&:nth-child(odd):not(:nth-child(3)) {
color: #ff0000;
}
Expand Down