[Pkg-javascript-commits] [less.js] 141/285: Fix interpolated selector match regression
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:48 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 a51c8480efaf12d8071a5f5192770aa13cf3cc70
Author: seven-phases-max <seven.phases.max at gmail.com>
Date: Sat Oct 4 20:19:50 2014 +0400
Fix interpolated selector match regression
---
lib/less/tree/selector.js | 46 ++++++++++++--------------------------
test/css/mixins-interpolated.css | 4 ++++
test/less/mixins-interpolated.less | 6 +++++
3 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/lib/less/tree/selector.js b/lib/less/tree/selector.js
index e27e70f..993d237 100644
--- a/lib/less/tree/selector.js
+++ b/lib/less/tree/selector.js
@@ -50,41 +50,23 @@ Selector.prototype.match = function (other) {
return olen; // return number of matched elements
};
-Selector.prototype.CacheElements = function(){
- var css = '', len, v, i;
+Selector.prototype.CacheElements = function() {
+ if (this._elements)
+ return;
+
+ var elements = this.elements.map( function(v) {
+ return v.combinator.value + (v.value.value || v.value);
+ }).join("").match(/[,&#\*\.\w-]([\w-]|(\\.))*/g);
- if( !this._elements ){
-
- len = this.elements.length;
- for(i = 0; i < len; i++){
-
- v = this.elements[i];
- css += v.combinator.value;
-
- if( !v.value.value ){
- css += v.value;
- continue;
- }
-
- if( typeof v.value.value !== "string" ){
- css = '';
- break;
- }
- css += v.value.value;
+ if (elements) {
+ if (elements[0] === "&") {
+ elements.shift();
}
-
- this._elements = css.match(/[,&#\*\.\w-]([\w-]|(\\.))*/g);
-
- if (this._elements) {
- if (this._elements[0] === "&") {
- this._elements.shift();
- }
-
- } else {
- this._elements = [];
- }
-
+ } else {
+ elements = [];
}
+
+ this._elements = elements;
};
Selector.prototype.isJustParentSelector = function() {
return !this.mediaEmpty &&
diff --git a/test/css/mixins-interpolated.css b/test/css/mixins-interpolated.css
index 637b5b6..0d511fc 100644
--- a/test/css/mixins-interpolated.css
+++ b/test/css/mixins-interpolated.css
@@ -1,3 +1,6 @@
+.123 {
+ a: 0;
+}
.foo {
a: 1;
}
@@ -11,6 +14,7 @@
a: 4;
}
mi-test-a {
+ a: 0;
a: 1;
a: 2;
a: 3;
diff --git a/test/less/mixins-interpolated.less b/test/less/mixins-interpolated.less
index 2e75e98..b79fa89 100644
--- a/test/less/mixins-interpolated.less
+++ b/test/less/mixins-interpolated.less
@@ -1,8 +1,13 @@
+ at a0: 123;
@a1: foo;
@a2: ~".foo";
@a4: ~"#foo";
+.@{a0} {
+ a: 0;
+}
+
.@{a1} {
a: 1;
}
@@ -20,6 +25,7 @@
}
mi-test-a {
+ .123;
.foo;
#foo;
}
--
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