default function: added error when used with css-guards. updated tests.

This commit is contained in:
seven-phases-max
2013-12-22 18:54:39 +04:00
parent bdfff94920
commit bbc15a413b
5 changed files with 41 additions and 1 deletions

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -0,0 +1,4 @@
selector when (default()) {
color: red;
}

View 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;

View File

@@ -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);
}
}