mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
if contrast first argument does not match, pass it through. Fixes #1090
This commit is contained in:
@@ -173,6 +173,11 @@ tree.functions = {
|
||||
return this.desaturate(color, new(tree.Dimension)(100));
|
||||
},
|
||||
contrast: function (color, dark, light, threshold) {
|
||||
// filter: contrast(3.2);
|
||||
// should be kept as is, so check for color
|
||||
if (!color.rgb) {
|
||||
return null;
|
||||
}
|
||||
if (typeof light === 'undefined') {
|
||||
light = this.rgba(255, 255, 255, 1.0);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ tree.Call.prototype = {
|
||||
// When evaluating a function call,
|
||||
// we either find the function in `tree.functions` [1],
|
||||
// in which case we call it, passing the evaluated arguments,
|
||||
// or we simply print it out as it appeared originally [2].
|
||||
// if this returns null or we cannot find the function, we
|
||||
// simply print it out as it appeared originally [2].
|
||||
//
|
||||
// The *functions.js* file contains the built-in functions.
|
||||
//
|
||||
@@ -23,21 +24,26 @@ tree.Call.prototype = {
|
||||
// The function should receive the value, not the variable.
|
||||
//
|
||||
eval: function (env) {
|
||||
var args = this.args.map(function (a) { return a.eval(env) });
|
||||
var args = this.args.map(function (a) { return a.eval(env) }),
|
||||
result;
|
||||
|
||||
if (this.name in tree.functions) { // 1.
|
||||
try {
|
||||
return tree.functions[this.name].apply(tree.functions, args);
|
||||
result = tree.functions[this.name].apply(tree.functions, args);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
} catch (e) {
|
||||
throw { type: e.type || "Runtime",
|
||||
message: "error evaluating function `" + this.name + "`" +
|
||||
(e.message ? ': ' + e.message : ''),
|
||||
index: this.index, filename: this.filename };
|
||||
}
|
||||
} else { // 2.
|
||||
return new(tree.Anonymous)(this.name +
|
||||
"(" + args.map(function (a) { return a.toCSS(env) }).join(', ') + ")");
|
||||
}
|
||||
|
||||
// 2.
|
||||
return new(tree.Anonymous)(this.name +
|
||||
"(" + args.map(function (a) { return a.toCSS(env) }).join(', ') + ")");
|
||||
},
|
||||
|
||||
toCSS: function (env) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
luma-yellow: 93%;
|
||||
luma-cyan: 79%;
|
||||
luma-white-alpha: 50%;
|
||||
contrast-filter: contrast(30%);
|
||||
contrast-white: #000000;
|
||||
contrast-black: #ffffff;
|
||||
contrast-red: #ffffff;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
luma-yellow: luma(#ffff00);
|
||||
luma-cyan: luma(#00ffff);
|
||||
luma-white-alpha: luma(rgba(255,255,255,0.5));
|
||||
contrast-filter: contrast(30%);
|
||||
contrast-white: contrast(#fff);
|
||||
contrast-black: contrast(#000);
|
||||
contrast-red: contrast(#ff0000);
|
||||
|
||||
Reference in New Issue
Block a user