Skip to content

Commit

Permalink
Merge pull request #2217 from seven-phases-max/2_0_0
Browse files Browse the repository at this point in the history
Fix interpolated selector match regression
  • Loading branch information
lukeapage committed Oct 4, 2014
2 parents 70bf802 + a51c848 commit 10296d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
46 changes: 14 additions & 32 deletions lib/less/tree/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
4 changes: 4 additions & 0 deletions test/css/mixins-interpolated.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.123 {
a: 0;
}
.foo {
a: 1;
}
Expand All @@ -11,6 +14,7 @@
a: 4;
}
mi-test-a {
a: 0;
a: 1;
a: 2;
a: 3;
Expand Down
6 changes: 6 additions & 0 deletions test/less/mixins-interpolated.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@

@a0: 123;
@a1: foo;
@a2: ~".foo";
@a4: ~"#foo";

.@{a0} {
a: 0;
}

.@{a1} {
a: 1;
}
Expand All @@ -20,6 +25,7 @@
}

mi-test-a {
.123;
.foo;
#foo;
}
Expand Down

0 comments on commit 10296d2

Please sign in to comment.