[Pkg-javascript-commits] [less.js] 99/285: Fix #1973
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.0.0
in repository less.js.
commit 9f68f4355282375866a74cc0e693a2abd40f8d5c
Author: seven-phases-max <seven.phases.max at gmail.com>
Date: Fri Sep 5 14:11:03 2014 +0400
Fix #1973
---
lib/less/tree/element.js | 13 +++++++++++--
test/css/selectors.css | 3 +++
test/less/selectors.less | 3 +++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lib/less/tree/element.js b/lib/less/tree/element.js
index 8142d11..cc1c83e 100644
--- a/lib/less/tree/element.js
+++ b/lib/less/tree/element.js
@@ -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;
diff --git a/test/css/selectors.css b/test/css/selectors.css
index 11909fe..85f95b5 100644
--- a/test/css/selectors.css
+++ b/test/css/selectors.css
@@ -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;
}
diff --git a/test/less/selectors.less b/test/less/selectors.less
index e641847..42aa29e 100644
--- a/test/less/selectors.less
+++ b/test/less/selectors.less
@@ -126,6 +126,9 @@ a {
selector: interpolated;
}
.test {
+ &:nth-child(@{num}) {
+ selector: interpolated;
+ }
&:nth-child(odd):not(:nth-child(3)) {
color: #ff0000;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list