mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
tweak mixin pattern matching to be more useful
This commit is contained in:
@@ -48,14 +48,14 @@ tree.mixin.Definition = function (name, params, rules) {
|
||||
this.rules = rules;
|
||||
this._lookups = {};
|
||||
this.required = params.reduce(function (count, p) {
|
||||
if (p.name && !p.value) { return count + 1 }
|
||||
else { return count }
|
||||
if (!p.name || (p.name && !p.value)) { return count + 1 }
|
||||
else { return count }
|
||||
}, 0);
|
||||
this.parent = tree.Ruleset.prototype;
|
||||
this.frames = [];
|
||||
};
|
||||
tree.mixin.Definition.prototype = {
|
||||
toCSS: function () { return "" },
|
||||
toCSS: function () { return "" },
|
||||
variable: function (name) { return this.parent.variable.call(this, name) },
|
||||
variables: function () { return this.parent.variables.call(this) },
|
||||
find: function () { return this.parent.find.apply(this, arguments) },
|
||||
@@ -81,7 +81,8 @@ tree.mixin.Definition.prototype = {
|
||||
match: function (args, env) {
|
||||
var argsLength = (args && args.length) || 0, len;
|
||||
|
||||
if (argsLength < this.required) { return false }
|
||||
if (argsLength < this.required) { return false }
|
||||
if ((this.required > 0) && (argsLength > this.params.length)) { return false }
|
||||
|
||||
len = Math.min(argsLength, this.arity);
|
||||
|
||||
|
||||
@@ -14,14 +14,12 @@
|
||||
.two {
|
||||
zero: 0;
|
||||
one: 1;
|
||||
one-req: 1;
|
||||
two: 2;
|
||||
three: 3;
|
||||
}
|
||||
.three {
|
||||
zero: 0;
|
||||
one: 1;
|
||||
one-req: 1;
|
||||
two: 2;
|
||||
three-req: 3;
|
||||
three: 3;
|
||||
@@ -41,15 +39,11 @@
|
||||
border-left: 4px;
|
||||
}
|
||||
.only-right {
|
||||
both: 330;
|
||||
right: 33;
|
||||
}
|
||||
.only-left {
|
||||
both: 330;
|
||||
left: 33;
|
||||
}
|
||||
.left-right {
|
||||
both: 330;
|
||||
left: 33;
|
||||
right: 33;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user