mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
First part of extend chaining
This commit is contained in:
38
test/css/extend-chaining.css
Normal file
38
test/css/extend-chaining.css
Normal file
@@ -0,0 +1,38 @@
|
||||
.a,
|
||||
.b,
|
||||
.c {
|
||||
color: black;
|
||||
}
|
||||
.f,
|
||||
.e,
|
||||
.d {
|
||||
color: black;
|
||||
}
|
||||
.g.h,
|
||||
.i.j.h,
|
||||
.k.j.h {
|
||||
color: black;
|
||||
}
|
||||
.i.j,
|
||||
.k.j {
|
||||
color: white;
|
||||
}
|
||||
.l,
|
||||
.m,
|
||||
.n,
|
||||
.o,
|
||||
.p,
|
||||
.q,
|
||||
.r,
|
||||
.s,
|
||||
.t {
|
||||
color: black;
|
||||
}
|
||||
.u,
|
||||
.v.u.v {
|
||||
color: black;
|
||||
}
|
||||
.w,
|
||||
.v.w.v {
|
||||
color: black;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
.sidebar,
|
||||
.sidebar2,
|
||||
.type1 .sidebar3 {
|
||||
.type1 .sidebar3,
|
||||
.type2.sidebar4 {
|
||||
width: 300px;
|
||||
background: red;
|
||||
}
|
||||
.sidebar .box,
|
||||
.sidebar2 .box,
|
||||
.type1 .sidebar3 .box {
|
||||
.type1 .sidebar3 .box,
|
||||
.type2.sidebar4 .box {
|
||||
background: #FFF;
|
||||
border: 1px solid #000;
|
||||
margin: 10px 0;
|
||||
@@ -17,3 +19,6 @@
|
||||
.type1 .sidebar3 {
|
||||
background: green;
|
||||
}
|
||||
.type2.sidebar4 {
|
||||
background: red;
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ div.ext7,
|
||||
width: 100px;
|
||||
}
|
||||
.ext8.ext9,
|
||||
.foo {
|
||||
.fuu {
|
||||
result: add-foo;
|
||||
}
|
||||
.ext8 .ext9,
|
||||
.ext8 + .ext9,
|
||||
.ext8 > .ext9,
|
||||
.bar,
|
||||
.buu,
|
||||
.zap,
|
||||
.zoo {
|
||||
result: bar-matched;
|
||||
@@ -49,15 +49,14 @@ div.ext7,
|
||||
result: none;
|
||||
}
|
||||
.ext8 .ext9,
|
||||
.bar {
|
||||
.buu {
|
||||
result: match-nested-bar;
|
||||
}
|
||||
.ext8.ext9,
|
||||
.foo {
|
||||
.fuu {
|
||||
result: match-nested-foo;
|
||||
}
|
||||
.aa,
|
||||
.bb,
|
||||
.cc {
|
||||
color: black;
|
||||
}
|
||||
|
||||
26
test/less/errors/extend-circular.less
Normal file
26
test/less/errors/extend-circular.less
Normal file
@@ -0,0 +1,26 @@
|
||||
// classic circular reference
|
||||
|
||||
.x:extend(.z) {}
|
||||
.y:extend(.x) {}
|
||||
.z:extend(.y) {}
|
||||
|
||||
//.x:extend(.z) {}
|
||||
//.y:extend(.x) {}
|
||||
//.z:extend(.y) {}
|
||||
//
|
||||
//.x:extend(.z), <-- target 1
|
||||
///y:extend(.z) {} <-- new 1
|
||||
//.y:extend(.x),
|
||||
//.z:extend(.x) {} <-- new
|
||||
//.z:extend(.y),
|
||||
//.x:extend(.y) {} <-- new
|
||||
//
|
||||
//.x:extend(.z),
|
||||
//.z:extend(.z), <--- last iteration 1 - .parent = target 1 - .parent =
|
||||
///y:extend(.z) {}
|
||||
//.y:extend(.x),
|
||||
//.x:extend(.x), <-- last iteration
|
||||
//.z:extend(.x) {}
|
||||
//.z:extend(.y), <-- potential match with 1 -> result in .z:extend(.y)
|
||||
//.y:extend(.y), <-- last iteration
|
||||
//.x:extend(.y) {}
|
||||
2
test/less/errors/extend-circular.txt
Normal file
2
test/less/errors/extend-circular.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
SyntaxError: extend circular reference detected. One of the circular extends is currently: .x:extend( .z) in {path}extend-circular.less on line null, column 0:
|
||||
1
|
||||
48
test/less/extend-chaining.less
Normal file
48
test/less/extend-chaining.less
Normal file
@@ -0,0 +1,48 @@
|
||||
//very simple chaining
|
||||
.a {
|
||||
color: black;
|
||||
}
|
||||
.b:extend(.a) {}
|
||||
.c:extend(.b) {}
|
||||
|
||||
//very simple chaining, ordering not important
|
||||
|
||||
.d:extend(.e) {}
|
||||
.e:extend(.f) {}
|
||||
.f {
|
||||
color: black;
|
||||
}
|
||||
|
||||
//extend with all
|
||||
|
||||
.g.h {
|
||||
color: black;
|
||||
}
|
||||
.i.j:extend(.g all) {
|
||||
color: white;
|
||||
}
|
||||
.k:extend(.i all) {}
|
||||
|
||||
//extend multi-chaining
|
||||
|
||||
.l {
|
||||
color: black;
|
||||
}
|
||||
.m:extend(.l){}
|
||||
.n:extend(.m){}
|
||||
.o:extend(.n){}
|
||||
.p:extend(.o){}
|
||||
.q:extend(.p){}
|
||||
.r:extend(.q){}
|
||||
.s:extend(.r){}
|
||||
.t:extend(.s){}
|
||||
|
||||
// self referencing is ignored
|
||||
|
||||
.u {color: black;}
|
||||
.v.u.v:extend(.u all){}
|
||||
|
||||
// circular reference because the new extend product will match the existing extend
|
||||
|
||||
.w:extend(.w) {color: black;}
|
||||
.v.w.v:extend(.w all){}
|
||||
@@ -20,3 +20,10 @@
|
||||
background: green;
|
||||
}
|
||||
}
|
||||
|
||||
.type2 {
|
||||
&.sidebar4 {
|
||||
&:extend(.sidebar all);
|
||||
background: red;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ div.ext5,
|
||||
}
|
||||
}
|
||||
|
||||
.foo:extend(.ext8.ext9 all) {}
|
||||
.bar:extend(.ext8 .ext9 all) {}
|
||||
.fuu:extend(.ext8.ext9 all) {}
|
||||
.buu:extend(.ext8 .ext9 all) {}
|
||||
.zap:extend(.ext8 + .ext9 all) {}
|
||||
.zoo:extend(.ext8 > .ext9 all) {}
|
||||
|
||||
@@ -70,7 +70,7 @@ div.ext5,
|
||||
background: red;
|
||||
}
|
||||
}
|
||||
.bb:extend(.aa) {
|
||||
.bb {
|
||||
background: red;
|
||||
.bb {
|
||||
color: black;
|
||||
|
||||
Reference in New Issue
Block a user