Skip to content

Commit

Permalink
Fixed extend leaking through nested parent selector. less#2586
Browse files Browse the repository at this point in the history
  • Loading branch information
meri committed Dec 13, 2015
1 parent e753a7e commit dd09691
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/less/tree/ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
if (addPath.length > 0) {
// /deep/ is a combinator that is valid without anything in front of it
// so if the & does not have a combinator that is "" or " " then
// and there is a combinator on the parent, then grab that.
// and there is a combinator o n the parent, then grab that.
// this also allows + a { & .b { .a & { ... though not sure why you would want to do that
var combinator = replacedElement.combinator, parentEl = addPath[0].elements[0];
if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {
Expand All @@ -623,7 +623,11 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {

//put together the parent selectors after the join (e.g. the rest of the parent)
if (addPath.length > 1) {
newSelectorPath = newSelectorPath.concat(addPath.slice(1));
var restOfPath = addPath.slice(1);
restOfPath = restOfPath.map(function (selector) {
return selector.createDerived(selector.elements, []);
});
newSelectorPath = newSelectorPath.concat(restOfPath);
}
return newSelectorPath;
}
Expand Down
7 changes: 7 additions & 0 deletions test/css/extend-selector.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@ div.ext7,
.footer .footer-nav:before {
background: blue;
}
.issue-2586-bordered,
.issue-2586-somepage .content {
border: solid 1px black;
}
.issue-2586-somepage .content > span {
margin-bottom: 10px;
}
13 changes: 12 additions & 1 deletion test/less/extend-selector.less
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,15 @@ div.ext5,
.footer-nav {
&:extend( .header .header-nav all );
}
}
}

.issue-2586-bordered {
border: solid 1px black;
}
.issue-2586-somepage {
.content:extend(.issue-2586-bordered) {
&>span {
margin-bottom: 10px;
}
}
}

0 comments on commit dd09691

Please sign in to comment.