10000 support for deep but exact extend · nullstring/less.js@7cebd9c · GitHub
[go: up one dir, main page]

Skip to content

Commit 7cebd9c

Browse files
committed
support for deep but exact extend
1 parent 62cc6cf commit 7cebd9c

File tree

6 files changed

+110
-7
lines changed

6 files changed

+110
-7
lines changed

lib/less/extend-visitor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@
177177

178178
if (potentialMatch) {
179179
potentialMatch.finished = potentialMatch.matched === extend.selector.elements.length;
180-
if (potentialMatch.finished && (
181-
(!extend.any && i+1 < selector.elements.length) ||
182-
(!extend.deep && k+1 < selectorPath.length))) {
180+
if (potentialMatch.finished &&
181+
(!extend.deep && (i+1 < selector.elements.length ||
182+
8000 k+1 < selectorPath.length))) {
183183
potentialMatch = null;
184184
}
185185
}

lib/less/parser.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,6 @@ less.Parser = function Parser(env) {
804804

805805
option = option && option[1];
806806

807-
if (option != "all" && option) {
808-
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");
809-
}
810-
811807
if (isRule) {
812808
expect(/^;/);
813809
}

test/css/extend-deep.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.replace.replace .replace,
2+
.c.replace + .replace .replace,
3+
.replace.replace .c,
4+
.c.replace + .replace .c,
5+
.rep_ace,
6+
.effected.replace + .replace .replace,
7+
.effected.replace + .replace .c {
8+
prop: copy-paste-replace;
9+
}
10+
.replace.replace .replace .d,
11+
.c.replace + .replace .replace .d,
12+
.replace.replace .c .d,
13+
.c.replace + .replace .c .d,
14+
.rep_ace .d,
15+
.effected.replace + .replace .replace .d,
16+
.effected.replace + .replace .c .d {
17+
prop: deep;
18+
}
19+
.a .b .c,
20+
.effected .b .c {
21+
prop: is_effected;
22+
}
23+
.a,
24+
.effected {
25+
prop: is_effected;
26+
}
27+
.a .b,
28+
.effected .b {
29+
prop: is_effected;
30+
}
31+
.a .b.c,
32+
.effected .b.c {
33+
prop: is_effected;
34+
}
35+
.b .a {
36+
prop: not_effected;
37+
}
38+
.a:hover,
39+
.effected:hover {
40+
hover: is_effected;
41+
}
42+
.e.e,
43+
.dbl {
44+
prop: extend-double;
45+
}
46+
.e.e:hover,
47+
.dbl:hover {
48+
hover: up;
49+
}

test/css/extend-exact.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232
.dbl {
3333
prop: extend-double;
3434
}
35+
.e.e:hover {
36+
hover: not-extended;
37+
}

test/less/extend-deep.less

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.replace.replace,
2+
.c.replace + .replace {
3+
.replace,
4+
.c {
5+
prop: copy-paste-replace;
6+
.d {
7+
prop: deep;
8+
}
9+
}
10+
}
11+
.rep_ace:extend(.replace.replace .replace deep) {}
12+
13+
.a .b .c {
14+
prop: is_effected;
15+
}
16+
17+
.a {
18+
prop: is_effected;
19+
.b {
20+
prop: is_effected;
21+
}
22+
.b.c {
23+
prop: is_effected;
24+
}
25+
}
26+
27+
.b {
28+
.a {
29+
prop: not_effected;
30+
}
31+
}
32+
33+
.a {
34+
&:hover {
35+
hover: is_effected;
36+
}
37+
}
38+
39+
.effected {
40+
&:extend(.a deep);
41+
&:extend(.c deep);
42+
}
43+
44+
.e {
45+
&& {
46+
prop: extend-double;
47+
&:hover {
48+
hover: up;
49+
}
50+
}
51+
}
52+
.dbl:extend(.e.e deep) {}

test/less/extend-exact.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
.e {
3939
&& {
4040
prop: extend-double;
41+
&:hover {
42+
hover: not-extended;
43+
}
4144
}
4245
}
4346
.dbl:extend(.e.e) {}

0 commit comments

Comments
 (0)
0