mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Merge remote-tracking branch 'origin/master' into detached-rulesets
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "less",
|
||||
"version": "1.6.3",
|
||||
"main": "./dist/less-1.6.3.js",
|
||||
"version": "1.6.2",
|
||||
"main": "./dist/less-1.6.2.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"benchmark",
|
||||
|
||||
@@ -264,28 +264,34 @@ tree.functions = {
|
||||
_minmax: function (isMin, args) {
|
||||
args = Array.prototype.slice.call(args);
|
||||
switch(args.length) {
|
||||
case 0: throw { type: "Argument", message: "one or more arguments required" };
|
||||
case 1: return args[0];
|
||||
case 0: throw { type: "Argument", message: "one or more arguments required" };
|
||||
}
|
||||
var i, j, current, currentUnified, referenceUnified, unit,
|
||||
var i, j, current, currentUnified, referenceUnified, unit, unitStatic, unitClone,
|
||||
order = [], // elems only contains original argument values.
|
||||
values = {}; // key is the unit.toString() for unified tree.Dimension values,
|
||||
// value is the index into the order array.
|
||||
for (i = 0; i < args.length; i++) {
|
||||
current = args[i];
|
||||
if (!(current instanceof tree.Dimension)) {
|
||||
order.push(current);
|
||||
if(Array.isArray(args[i].value)) {
|
||||
Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
currentUnified = current.unify();
|
||||
unit = currentUnified.unit.toString();
|
||||
j = values[unit];
|
||||
currentUnified = current.unit.toString() === "" && unitClone !== undefined ? new(tree.Dimension)(current.value, unitClone).unify() : current.unify();
|
||||
unit = currentUnified.unit.toString() === "" && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
|
||||
unitStatic = unit !== "" && unitStatic === undefined || unit !== "" && order[0].unify().unit.toString() === "" ? unit : unitStatic;
|
||||
unitClone = unit !== "" && unitClone === undefined ? current.unit.toString() : unitClone;
|
||||
j = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit];
|
||||
if (j === undefined) {
|
||||
if(unitStatic !== undefined && unit !== unitStatic) {
|
||||
throw{ type: "Argument", message: "incompatible types" };
|
||||
}
|
||||
values[unit] = order.length;
|
||||
order.push(current);
|
||||
continue;
|
||||
}
|
||||
referenceUnified = order[j].unify();
|
||||
referenceUnified = order[j].unit.toString() === "" && unitClone !== undefined ? new(tree.Dimension)(order[j].value, unitClone).unify() : order[j].unify();
|
||||
if ( isMin && currentUnified.value < referenceUnified.value ||
|
||||
!isMin && currentUnified.value > referenceUnified.value) {
|
||||
order[j] = current;
|
||||
@@ -294,8 +300,7 @@ tree.functions = {
|
||||
if (order.length == 1) {
|
||||
return order[0];
|
||||
}
|
||||
args = order.map(function (a) { return a.toCSS(this.env); })
|
||||
.join(this.env.compress ? "," : ", ");
|
||||
args = order.map(function (a) { return a.toCSS(this.env); }).join(this.env.compress ? "," : ", ");
|
||||
return new(tree.Anonymous)((isMin ? "min" : "max") + "(" + args + ")");
|
||||
},
|
||||
min: function () {
|
||||
@@ -304,6 +309,9 @@ tree.functions = {
|
||||
max: function () {
|
||||
return this._minmax(false, arguments);
|
||||
},
|
||||
"get-unit": function (n) {
|
||||
return new(tree.Anonymous)(n.unit);
|
||||
},
|
||||
argb: function (color) {
|
||||
return new(tree.Anonymous)(color.toARGB());
|
||||
},
|
||||
|
||||
@@ -89,17 +89,27 @@ tree.Dimension.prototype = {
|
||||
|
||||
compare: function (other) {
|
||||
if (other instanceof tree.Dimension) {
|
||||
var a = this.unify(), b = other.unify(),
|
||||
aValue = a.value, bValue = b.value;
|
||||
var a, b,
|
||||
aValue, bValue;
|
||||
|
||||
if (this.unit.isEmpty() || other.unit.isEmpty()) {
|
||||
a = this;
|
||||
b = other;
|
||||
} else {
|
||||
a = this.unify();
|
||||
b = other.unify();
|
||||
if (a.unit.compare(b.unit) !== 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
aValue = a.value;
|
||||
bValue = b.value;
|
||||
|
||||
if (bValue > aValue) {
|
||||
return -1;
|
||||
} else if (bValue < aValue) {
|
||||
return 1;
|
||||
} else {
|
||||
if (!b.unit.isEmpty() && a.unit.compare(b.unit) !== 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -108,7 +118,7 @@ tree.Dimension.prototype = {
|
||||
},
|
||||
|
||||
unify: function () {
|
||||
return this.convertTo({ length: 'm', duration: 's', angle: 'rad' });
|
||||
return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });
|
||||
},
|
||||
|
||||
convertTo: function (conversions) {
|
||||
@@ -161,6 +171,7 @@ tree.UnitConversions = {
|
||||
'cm': 0.01,
|
||||
'mm': 0.001,
|
||||
'in': 0.0254,
|
||||
'px': 0.0254 / 96,
|
||||
'pt': 0.0254 / 72,
|
||||
'pc': 0.0254 / 72 * 12
|
||||
},
|
||||
|
||||
@@ -187,14 +187,15 @@ tree.mixin.Definition.prototype = {
|
||||
var frame = new(tree.Ruleset)(null, null),
|
||||
varargs, arg,
|
||||
params = this.params.slice(0),
|
||||
i, j, val, name, isNamedFound, argIndex;
|
||||
i, j, val, name, isNamedFound, argIndex, argsLength = 0;
|
||||
|
||||
mixinEnv = new tree.evalEnv(mixinEnv, [frame].concat(mixinEnv.frames));
|
||||
|
||||
if (args) {
|
||||
args = args.slice(0);
|
||||
argsLength = args.length;
|
||||
|
||||
for(i = 0; i < args.length; i++) {
|
||||
for(i = 0; i < argsLength; i++) {
|
||||
arg = args[i];
|
||||
if (name = (arg && arg.name)) {
|
||||
isNamedFound = false;
|
||||
@@ -224,9 +225,9 @@ tree.mixin.Definition.prototype = {
|
||||
arg = args && args[argIndex];
|
||||
|
||||
if (name = params[i].name) {
|
||||
if (params[i].variadic && args) {
|
||||
if (params[i].variadic) {
|
||||
varargs = [];
|
||||
for (j = argIndex; j < args.length; j++) {
|
||||
for (j = argIndex; j < argsLength; j++) {
|
||||
varargs.push(args[j].value.eval(env));
|
||||
}
|
||||
frame.prependRule(new(tree.Rule)(name, new(tree.Expression)(varargs).eval(env)));
|
||||
@@ -239,7 +240,7 @@ tree.mixin.Definition.prototype = {
|
||||
frame.resetCache();
|
||||
} else {
|
||||
throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
|
||||
' (' + args.length + ' for ' + this.arity + ')' };
|
||||
' (' + argsLength + ' for ' + this.arity + ')' };
|
||||
}
|
||||
|
||||
frame.prependRule(new(tree.Rule)(name, val));
|
||||
@@ -248,7 +249,7 @@ tree.mixin.Definition.prototype = {
|
||||
}
|
||||
|
||||
if (params[i].variadic && args) {
|
||||
for (j = argIndex; j < args.length; j++) {
|
||||
for (j = argIndex; j < argsLength; j++) {
|
||||
evaldArguments[j] = args[j].value.eval(env);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
eformat: rgb(32, 128, 64);
|
||||
unitless: 12;
|
||||
unit: 14em;
|
||||
get-unit: px;
|
||||
get-unit-empty: ;
|
||||
hue: 98;
|
||||
saturation: 12%;
|
||||
lightness: 95%;
|
||||
@@ -82,10 +84,11 @@
|
||||
pow: 64;
|
||||
pow: 27;
|
||||
min: 0;
|
||||
min: min("junk", 5);
|
||||
min: 3pt;
|
||||
min: 5;
|
||||
min: 1pt;
|
||||
min: 3mm;
|
||||
max: 3;
|
||||
max: max(8%, 1cm);
|
||||
max: 5em;
|
||||
percentage: 20%;
|
||||
color: #ff0011;
|
||||
tint: #898989;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
.zero {
|
||||
variadic: true;
|
||||
named-variadic: true;
|
||||
zero: 0;
|
||||
one: 1;
|
||||
two: 2;
|
||||
@@ -7,6 +8,7 @@
|
||||
}
|
||||
.one {
|
||||
variadic: true;
|
||||
named-variadic: true;
|
||||
one: 1;
|
||||
one-req: 1;
|
||||
two: 2;
|
||||
@@ -14,11 +16,13 @@
|
||||
}
|
||||
.two {
|
||||
variadic: true;
|
||||
named-variadic: true;
|
||||
two: 2;
|
||||
three: 3;
|
||||
}
|
||||
.three {
|
||||
variadic: true;
|
||||
named-variadic: true;
|
||||
three-req: 3;
|
||||
three: 3;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
|
||||
unitless: unit(12px);
|
||||
unit: unit((13px + 1px), em);
|
||||
|
||||
get-unit: get-unit(10px);
|
||||
get-unit-empty: get-unit(10);
|
||||
|
||||
hue: hue(hsl(98, 12%, 95%));
|
||||
saturation: saturation(hsl(98, 12%, 95%));
|
||||
@@ -88,10 +91,11 @@
|
||||
pow: pow(4, 3);
|
||||
pow: pow(3, 3em);
|
||||
min: min(0);
|
||||
min: min("junk", 6, 5);
|
||||
min: min(1pc, 3pt);
|
||||
min: min(6, 5);
|
||||
min: min(1pt, 3pt);
|
||||
min: min(1cm, 3mm);
|
||||
max: max(1, 3);
|
||||
max: max(3%, 1cm, 8%, 2mm);
|
||||
max: max(3em, 1em, 2em, 5em);
|
||||
percentage: percentage((10px / 50));
|
||||
color: color("#ff0011");
|
||||
tint: tint(#777777, 13);
|
||||
|
||||
@@ -150,4 +150,10 @@
|
||||
.call-inner-lock-mixin {
|
||||
.inner-locked-mixin();
|
||||
}
|
||||
}
|
||||
}
|
||||
.bug-100cm-1m(@a) when (@a = 1) {
|
||||
.failed {
|
||||
one-hundred: not-equal-to-1;
|
||||
}
|
||||
}
|
||||
.bug-100cm-1m(100cm);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
.mixin (...) {
|
||||
variadic: true;
|
||||
}
|
||||
.mixin (@a...) {
|
||||
named-variadic: true;
|
||||
}
|
||||
.mixin () {
|
||||
zero: 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user