mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
default function: added error when used with css-guards. updated tests.
This commit is contained in:
@@ -19,12 +19,18 @@ tree.Ruleset.prototype = {
|
||||
}
|
||||
},
|
||||
eval: function (env) {
|
||||
var thisSelectors = this.selectors, selectors, selCnt, i;
|
||||
var thisSelectors = this.selectors, selectors,
|
||||
selCnt, i, defaultFunc = tree.defaultFunc;
|
||||
if (thisSelectors && (selCnt = thisSelectors.length)) {
|
||||
selectors = [];
|
||||
defaultFunc.error({
|
||||
type: "Syntax",
|
||||
message: "it is currently only allowed in parametric mixin guards,"
|
||||
});
|
||||
for (i = 0; i < selCnt; i++) {
|
||||
selectors.push(thisSelectors[i].eval(env));
|
||||
}
|
||||
defaultFunc.reset();
|
||||
}
|
||||
|
||||
var rules = this.rules ? this.rules.slice(0) : null,
|
||||
|
||||
@@ -112,3 +112,9 @@ guard-default-multi-4 {
|
||||
always: 2;
|
||||
case: 2;
|
||||
}
|
||||
guard-default-scopes-3 {
|
||||
3: when default;
|
||||
}
|
||||
guard-default-scopes-1 {
|
||||
1: no condition;
|
||||
}
|
||||
|
||||
4
test/less/errors/css-guard-default-func.less
Normal file
4
test/less/errors/css-guard-default-func.less
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
selector when (default()) {
|
||||
color: red;
|
||||
}
|
||||
4
test/less/errors/css-guard-default-func.txt
Normal file
4
test/less/errors/css-guard-default-func.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
SyntaxError: error evaluating function `default`: it is currently only allowed in parametric mixin guards, in {path}css-guard-default-func.less on line 2, column 16:
|
||||
1
|
||||
2 selector when (default()) {
|
||||
3 color: red;
|
||||
@@ -157,3 +157,23 @@ guard-default-multi-4 {
|
||||
.m(1);
|
||||
.m(2);
|
||||
}
|
||||
|
||||
// default & scope
|
||||
|
||||
guard-default-scopes {
|
||||
.s1() {.m(@v) {1: no condition}}
|
||||
.s2() {.m(@v) when (@v) {2: when true}}
|
||||
.s3() {.m(@v) when (default()) {3: when default}}
|
||||
|
||||
&-3 {
|
||||
.s2();
|
||||
.s3();
|
||||
.m(false);
|
||||
}
|
||||
|
||||
&-1 {
|
||||
.s1();
|
||||
.s3();
|
||||
.m(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user