mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
support for deep but exact extend
This commit is contained in:
@@ -177,9 +177,9 @@
|
||||
|
||||
if (potentialMatch) {
|
||||
potentialMatch.finished = potentialMatch.matched === extend.selector.elements.length;
|
||||
if (potentialMatch.finished && (
|
||||
(!extend.any && i+1 < selector.elements.length) ||
|
||||
(!extend.deep && k+1 < selectorPath.length))) {
|
||||
if (potentialMatch.finished &&
|
||||
(!extend.deep && (i+1 < selector.elements.length ||
|
||||
k+1 < selectorPath.length))) {
|
||||
potentialMatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -804,10 +804,6 @@ less.Parser = function Parser(env) {
|
||||
|
||||
option = option && option[1];
|
||||
|
||||
if (option != "all" && option) {
|
||||
error(":extend only supports the all option at the moment, please specify it after your selector, e.g. :extend(.a all) or specify no option to extend shallow and exact");
|
||||
}
|
||||
|
||||
if (isRule) {
|
||||
expect(/^;/);
|
||||
}
|
||||
|
||||
49
test/css/extend-deep.css
Normal file
49
test/css/extend-deep.css
Normal file
@@ -0,0 +1,49 @@
|
||||
.replace.replace .replace,
|
||||
.c.replace + .replace .replace,
|
||||
.replace.replace .c,
|
||||
.c.replace + .replace .c,
|
||||
.rep_ace,
|
||||
.effected.replace + .replace .replace,
|
||||
.effected.replace + .replace .c {
|
||||
prop: copy-paste-replace;
|
||||
}
|
||||
.replace.replace .replace .d,
|
||||
.c.replace + .replace .replace .d,
|
||||
.replace.replace .c .d,
|
||||
.c.replace + .replace .c .d,
|
||||
.rep_ace .d,
|
||||
.effected.replace + .replace .replace .d,
|
||||
.effected.replace + .replace .c .d {
|
||||
prop: deep;
|
||||
}
|
||||
.a .b .c,
|
||||
.effected .b .c {
|
||||
prop: is_effected;
|
||||
}
|
||||
.a,
|
||||
.effected {
|
||||
prop: is_effected;
|
||||
}
|
||||
.a .b,
|
||||
.effected .b {
|
||||
prop: is_effected;
|
||||
}
|
||||
.a .b.c,
|
||||
.effected .b.c {
|
||||
prop: is_effected;
|
||||
}
|
||||
.b .a {
|
||||
prop: not_effected;
|
||||
}
|
||||
.a:hover,
|
||||
.effected:hover {
|
||||
hover: is_effected;
|
||||
}
|
||||
.e.e,
|
||||
.dbl {
|
||||
prop: extend-double;
|
||||
}
|
||||
.e.e:hover,
|
||||
.dbl:hover {
|
||||
hover: up;
|
||||
}
|
||||
@@ -32,3 +32,6 @@
|
||||
.dbl {
|
||||
prop: extend-double;
|
||||
}
|
||||
.e.e:hover {
|
||||
hover: not-extended;
|
||||
}
|
||||
|
||||
52
test/less/extend-deep.less
Normal file
52
test/less/extend-deep.less
Normal file
@@ -0,0 +1,52 @@
|
||||
.replace.replace,
|
||||
.c.replace + .replace {
|
||||
.replace,
|
||||
.c {
|
||||
prop: copy-paste-replace;
|
||||
.d {
|
||||
prop: deep;
|
||||
}
|
||||
}
|
||||
}
|
||||
.rep_ace:extend(.replace.replace .replace deep) {}
|
||||
|
||||
.a .b .c {
|
||||
prop: is_effected;
|
||||
}
|
||||
|
||||
.a {
|
||||
prop: is_effected;
|
||||
.b {
|
||||
prop: is_effected;
|
||||
}
|
||||
.b.c {
|
||||
prop: is_effected;
|
||||
}
|
||||
}
|
||||
|
||||
.b {
|
||||
.a {
|
||||
prop: not_effected;
|
||||
}
|
||||
}
|
||||
|
||||
.a {
|
||||
&:hover {
|
||||
hover: is_effected;
|
||||
}
|
||||
}
|
||||
|
||||
.effected {
|
||||
&:extend(.a deep);
|
||||
&:extend(.c deep);
|
||||
}
|
||||
|
||||
.e {
|
||||
&& {
|
||||
prop: extend-double;
|
||||
&:hover {
|
||||
hover: up;
|
||||
}
|
||||
}
|
||||
}
|
||||
.dbl:extend(.e.e deep) {}
|
||||
@@ -38,6 +38,9 @@
|
||||
.e {
|
||||
&& {
|
||||
prop: extend-double;
|
||||
&:hover {
|
||||
hover: not-extended;
|
||||
}
|
||||
}
|
||||
}
|
||||
.dbl:extend(.e.e) {}
|
||||
|
||||
Reference in New Issue
Block a user