mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
Do not require default mixin. Fixes #926
This commit is contained in:
@@ -10,7 +10,7 @@ tree.mixin.Call = function (elements, args, index, filename, important) {
|
||||
};
|
||||
tree.mixin.Call.prototype = {
|
||||
eval: function (env) {
|
||||
var mixins, args, rules = [], match = false, i, m, f, isRecursive, isOneFound;
|
||||
var mixins, mixin, args, rules = [], match = false, i, m, f, isRecursive, isOneFound;
|
||||
|
||||
args = this.arguments && this.arguments.map(function (a) {
|
||||
return { name: a.name, value: a.value.eval(env) };
|
||||
@@ -20,9 +20,10 @@ tree.mixin.Call.prototype = {
|
||||
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
|
||||
isOneFound = true;
|
||||
for (m = 0; m < mixins.length; m++) {
|
||||
mixin = mixins[m];
|
||||
isRecursive = false;
|
||||
for(f = 0; f < env.frames.length; f++) {
|
||||
if ((!(mixins[m] instanceof tree.mixin.Definition)) && mixins[m] === (env.frames[f].originalRuleset || env.frames[f])) {
|
||||
if ((!(mixin instanceof tree.mixin.Definition)) && mixin === (env.frames[f].originalRuleset || env.frames[f])) {
|
||||
isRecursive = true;
|
||||
break;
|
||||
}
|
||||
@@ -30,14 +31,16 @@ tree.mixin.Call.prototype = {
|
||||
if (isRecursive) {
|
||||
continue;
|
||||
}
|
||||
if (mixins[m].match(args, env)) {
|
||||
try {
|
||||
Array.prototype.push.apply(
|
||||
rules, mixins[m].eval(env, this.arguments, this.important).rules);
|
||||
match = true;
|
||||
} catch (e) {
|
||||
throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
|
||||
if (mixin.matchArgs(args, env)) {
|
||||
if (!mixin.matchCondition || mixin.matchCondition(args, env)) {
|
||||
try {
|
||||
Array.prototype.push.apply(
|
||||
rules, mixin.eval(env, this.arguments, this.important).rules);
|
||||
} catch (e) {
|
||||
throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
|
||||
}
|
||||
}
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
@@ -167,7 +170,13 @@ tree.mixin.Definition.prototype = {
|
||||
ruleset.originalRuleset = this;
|
||||
return ruleset;
|
||||
},
|
||||
match: function (args, env) {
|
||||
matchCondition: function (args, env) {
|
||||
if (this.condition && !this.condition.eval({
|
||||
frames: [this.evalParams(env, args, [])].concat(env.frames)
|
||||
})) { return false }
|
||||
return true;
|
||||
},
|
||||
matchArgs: function (args, env) {
|
||||
var argsLength = (args && args.length) || 0, len, frame;
|
||||
|
||||
if (! this.variadic) {
|
||||
@@ -176,10 +185,6 @@ tree.mixin.Definition.prototype = {
|
||||
if ((this.required > 0) && (argsLength > this.params.length)) { return false }
|
||||
}
|
||||
|
||||
if (this.condition && !this.condition.eval({
|
||||
frames: [this.evalParams(env, args, [])].concat(env.frames)
|
||||
})) { return false }
|
||||
|
||||
len = Math.min(argsLength, this.arity);
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
|
||||
@@ -85,7 +85,7 @@ tree.Ruleset.prototype = {
|
||||
}
|
||||
}), this.strictImports);
|
||||
},
|
||||
match: function (args) {
|
||||
matchArgs: function (args) {
|
||||
return !args || args.length === 0;
|
||||
},
|
||||
variables: function () {
|
||||
|
||||
@@ -99,8 +99,6 @@
|
||||
.equality-unit-test(@num) when (@num = 2) {
|
||||
test: pass;
|
||||
}
|
||||
.equality-unit-test(@num) {
|
||||
}
|
||||
.equality-units {
|
||||
.equality-unit-test(1px);
|
||||
.equality-unit-test(2px);
|
||||
|
||||
Reference in New Issue
Block a user