Skip to content

Commit

Permalink
Proposed solution for issue less#1554. Adds supporto to the & sel…
Browse files Browse the repository at this point in the history
…ector in extend function arguments.
  • Loading branch information
Pedro Correia committed Sep 20, 2013
1 parent ee11dfb commit 1e2a7f5
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/less/extend-visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@
return matches;
},
isElementValuesEqual: function(elementValue1, elementValue2) {
if ( elementValue1 === '&' ) {
return true;
}
if (typeof elementValue1 === "string" || typeof elementValue2 === "string") {
return elementValue1 === elementValue2;
}
Expand Down
40 changes: 40 additions & 0 deletions test/css/extend-nest.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,43 @@
.amp-test-f.amp-test-c .amp-test-b.amp-test-d.amp-test-b.amp-test-e + .amp-test-c .amp-test-b.amp-test-d.amp-test-b.amp-test-e.amp-test-g {
test: extended by masses of selectors;
}
.amp-test-i.amp-test-j,
.amp-test-i.amp-test-k {
color: black;
background: white;
}
.amp-test-i.amp-test-k {
background: red;
}
.amp-test-all.all-a,
.amp-test-all.all-b {
color: black;
background: white;
}
.amp-test-all.all-a:hover,
.amp-test-all.all-b:hover {
color: green;
}
.amp-test-all.all-b {
background: red;
}
.deeper-amp-test {
background: black;
}
.deeper-amp-test.level-1,
.deeper-amp-test.level-2 {
background: magenta;
color: black;
}
.deeper-amp-test.level-1 .sub-level-1,
.deeper-amp-test.level-2 .sub-level-1 {
background: red;
color: white;
}
.deeper-amp-test.level-1 .sub-level-2,
.deeper-amp-test.level-2 .sub-level-2 {
background: green;
}
.deeper-amp-test.level-2 {
color: blue;
}
44 changes: 43 additions & 1 deletion test/less/extend-nest.less
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,46 @@
}
.amp-test-h {
test: extended by masses of selectors;
}
}

.amp-test-i {
&.amp-test-j {
color: black;
background: white;
}
&.amp-test-k {
&:extend(&.amp-test-j);
background: red;
}
}

.amp-test-all {
&.all-a {
color: black;
background: white;
&:hover {
color: green;
}
}
&.all-b {
&:extend(&.all-a all);
background: red;
}
}
.deeper-amp-test {
background: black;
&.level-1 {
background: magenta;
color: black;
.sub-level-1 {
background: red;
color: white;
}
.sub-level-2:extend(.sub-level-1) {
background: green;
}
}
&.level-2:extend(&.level-1) {
color: blue;
}
}

0 comments on commit 1e2a7f5

Please sign in to comment.