mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Do not evaluate css with guards if the guards fail. Fixes #1873
This commit is contained in:
@@ -20,7 +20,8 @@ tree.Ruleset.prototype = {
|
||||
},
|
||||
eval: function (env) {
|
||||
var thisSelectors = this.selectors, selectors,
|
||||
selCnt, i, defaultFunc = tree.defaultFunc;
|
||||
selCnt, selector, i, defaultFunc = tree.defaultFunc, hasOnePassingSelector = false;
|
||||
|
||||
if (thisSelectors && (selCnt = thisSelectors.length)) {
|
||||
selectors = [];
|
||||
defaultFunc.error({
|
||||
@@ -28,9 +29,15 @@ tree.Ruleset.prototype = {
|
||||
message: "it is currently only allowed in parametric mixin guards,"
|
||||
});
|
||||
for (i = 0; i < selCnt; i++) {
|
||||
selectors.push(thisSelectors[i].eval(env));
|
||||
selector = thisSelectors[i].eval(env);
|
||||
selectors.push(selector);
|
||||
if (selector.evaldCondition) {
|
||||
hasOnePassingSelector = true;
|
||||
}
|
||||
}
|
||||
defaultFunc.reset();
|
||||
} else {
|
||||
hasOnePassingSelector = true;
|
||||
}
|
||||
|
||||
var rules = this.rules ? this.rules.slice(0) : null,
|
||||
@@ -45,6 +52,10 @@ tree.Ruleset.prototype = {
|
||||
if(this.debugInfo) {
|
||||
ruleset.debugInfo = this.debugInfo;
|
||||
}
|
||||
|
||||
if (!hasOnePassingSelector) {
|
||||
rules.length = 0;
|
||||
}
|
||||
|
||||
// push the current ruleset to the frames stack
|
||||
var envFrames = env.frames;
|
||||
@@ -122,10 +133,7 @@ tree.Ruleset.prototype = {
|
||||
// check if it can be folded in (e.g. & where)
|
||||
if (rule.selectors[0].isJustParentSelector()) {
|
||||
rsRules.splice(i--, 1);
|
||||
// cannot call if there is no selector, so we can just continue
|
||||
if (!rule.selectors[0].evaldCondition) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(var j = 0; j < rule.rules.length; j++) {
|
||||
subRule = rule.rules[j];
|
||||
if (!(subRule instanceof tree.Rule) || !subRule.variable) {
|
||||
|
||||
@@ -97,3 +97,6 @@
|
||||
.scope-check();
|
||||
@k:4px;
|
||||
}
|
||||
.errors-if-called when (@c = never) {
|
||||
.mixin-doesnt-exist();
|
||||
}
|
||||
Reference in New Issue
Block a user