Merge branch '2_0_0' of https://github.com/less/less.js into 2_0_0

This commit is contained in:
Luke Page
2014-09-05 23:32:44 +01:00
3 changed files with 17 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
var Node = require("./node.js"),
Paren = require("./paren.js"),
Combinator = require("./combinator.js");
var Element = function (combinator, value, index, currentFileInfo) {
@@ -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;

View File

@@ -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;
}

View File

@@ -126,6 +126,9 @@ a {
selector: interpolated;
}
.test {
&:nth-child(@{num}) {
selector: interpolated;
}
&:nth-child(odd):not(:nth-child(3)) {
color: #ff0000;
}