1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 13:52:26 +01:00

Fix Option.has() for multiple arguments

This commit is contained in:
Kris Maglione
2008-10-10 18:14:48 +00:00
parent 0da19dfb31
commit ec5a81a472

View File

@@ -129,8 +129,8 @@ liberator.Option = function (names, description, type, defaultValue, extraInfo)
let value = this.value; let value = this.value;
if (this.type == "stringlist") if (this.type == "stringlist")
value = this.value.split(","); value = this.value.split(",");
/* Return the number of matching arguments. */ /* Return whether some argument matches */
return Array.reduce(arguments, function (n, val) value.indexOf(val) >= 0, 0); return Array.some(arguments, function (val) value.indexOf(val) >= 0);
}; };
this.__defineGetter__("value", this.get); this.__defineGetter__("value", this.get);
@@ -626,14 +626,14 @@ liberator.Options = function () //{{{
newValue = liberator.util.uniq(Array.concat(opt.valueHas, opt.optionHas), true); newValue = liberator.util.uniq(Array.concat(opt.valueHas, opt.optionHas), true);
break; break;
case "-": case "-":
newValue = Array.filter(opt.optionHas, function (item) opt.valueHas.indexOf(item) == -1); newValue = opt.optionHas.filter(function (item) opt.valueHas.indexOf(item) == -1);
break; break;
default: default:
newValue = opt.valueHas; newValue = opt.valueHas;
if (opt.invert) if (opt.invert)
{ {
let keepValues = Array.filter(opt.optionHas, function (item) opt.valueHas.indexOf(item) == -1); let keepValues = opt.optionHas.filter(function (item) opt.valueHas.indexOf(item) == -1);
let addValues = Array.filter(opt.valueHas, function (item) opt.optionHas.indexOf(item) == -1); let addValues = opt.valueHas .filter(function (item) opt.optionHas.indexOf(item) == -1);
newValue = addValues.concat(keepValues); newValue = addValues.concat(keepValues);
} }
break; break;