[Pkg-javascript-commits] [less.js] 70/88: Fix a small scope issue with mixins when using parent selectors, introduced in 1.6.2. Fixes #1877
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:22:27 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v1.7.0
in repository less.js.
commit 7c90acaae62fbe1d26c4778974703d857bc6b213
Author: Luke Page <luke.a.page at gmail.com>
Date: Fri Feb 21 11:22:42 2014 +0000
Fix a small scope issue with mixins when using parent selectors, introduced in 1.6.2. Fixes #1877
---
lib/less/tree/ruleset.js | 33 +++++++++++++---------
test/css/scope.css | 3 ++
test/less/errors/mixin-not-visible-in-scope-1.less | 9 ++++++
test/less/errors/mixin-not-visible-in-scope-1.txt | 4 +++
test/less/scope.less | 25 ++++++++++++++++
5 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js
index 7571b0e..d657976 100644
--- a/lib/less/tree/ruleset.js
+++ b/lib/less/tree/ruleset.js
@@ -111,20 +111,25 @@ tree.Ruleset.prototype = {
rule = rsRules[i];
if (! (rule instanceof tree.mixin.Definition || rule instanceof tree.DetachedRuleset)) {
rsRules[i] = rule = rule.eval ? rule.eval(env) : rule;
- // for rulesets, check if it is a css guard and can be removed
- if (rule instanceof tree.Ruleset && rule.selectors && rule.selectors.length === 1) {
- // check if it can be folded in (e.g. & where)
- if (rule.selectors[0].isJustParentSelector()) {
- rsRules.splice(i--, 1);
- // cannot call if there is no selector, so we can just continue
- if (!rule.selectors[0].evaldCondition) {
- continue;
- }
- for(var j = 0; j < rule.rules.length; j++) {
- subRule = rule.rules[j];
- if (!(subRule instanceof tree.Rule) || !subRule.variable) {
- rsRules.splice(++i, 0, subRule);
- }
+ }
+ }
+
+ // Evaluate everything else
+ for (i = 0; i < rsRules.length; i++) {
+ rule = rsRules[i];
+ // for rulesets, check if it is a css guard and can be removed
+ if (rule instanceof tree.Ruleset && rule.selectors && rule.selectors.length === 1) {
+ // check if it can be folded in (e.g. & where)
+ if (rule.selectors[0].isJustParentSelector()) {
+ rsRules.splice(i--, 1);
+ // cannot call if there is no selector, so we can just continue
+ if (!rule.selectors[0].evaldCondition) {
+ continue;
+ }
+ for(var j = 0; j < rule.rules.length; j++) {
+ subRule = rule.rules[j];
+ if (!(subRule instanceof tree.Rule) || !subRule.variable) {
+ rsRules.splice(++i, 0, subRule);
}
}
}
diff --git a/test/css/scope.css b/test/css/scope.css
index baa0552..0e4c17d 100644
--- a/test/css/scope.css
+++ b/test/css/scope.css
@@ -33,3 +33,6 @@
scope: 'top level';
sub-scope-only: 'inside';
}
+#parentSelectorScope {
+ prop: #ffffff;
+}
diff --git a/test/less/errors/mixin-not-visible-in-scope-1.less b/test/less/errors/mixin-not-visible-in-scope-1.less
new file mode 100644
index 0000000..2842613
--- /dev/null
+++ b/test/less/errors/mixin-not-visible-in-scope-1.less
@@ -0,0 +1,9 @@
+.something {
+ & {
+ .a {value: a}
+ }
+
+ & {
+ .b {.a} // was Err. before 1.6.2
+ }
+}
\ No newline at end of file
diff --git a/test/less/errors/mixin-not-visible-in-scope-1.txt b/test/less/errors/mixin-not-visible-in-scope-1.txt
new file mode 100644
index 0000000..15e64dc
--- /dev/null
+++ b/test/less/errors/mixin-not-visible-in-scope-1.txt
@@ -0,0 +1,4 @@
+NameError: .a is undefined in {path}mixin-not-visible-in-scope-1.less on line 7, column 13:
+6 & {
+7 .b {.a} // was Err. before 1.6.2
+8 }
diff --git a/test/less/scope.less b/test/less/scope.less
index 36d3706..475b1f6 100644
--- a/test/less/scope.less
+++ b/test/less/scope.less
@@ -76,4 +76,29 @@
@subScopeOnly: 'inside';
//use the mixin
.mixinNoParam();
+}
+#parentSelectorScope {
+ @col: white;
+ & {
+ @col: black;
+ }
+ prop: @col;
+ & {
+ @col: black;
+ }
+}
+.test-empty-mixin() {
+}
+#parentSelectorScopeMixins {
+ & {
+ .test-empty-mixin() {
+ should: never seee 1;
+ }
+ }
+ .test-empty-mixin();
+ & {
+ .test-empty-mixin() {
+ should: never seee 2;
+ }
+ }
}
\ No newline at end of file
--
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