1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:27:59 +01:00

Only call update() in (Command|Option|Map)#init if the extra config map was specified.

This commit is contained in:
Doug Kearns
2009-11-17 13:56:12 +11:00
parent 230490db05
commit cb7cff5766
3 changed files with 21 additions and 25 deletions

View File

@@ -39,20 +39,17 @@ const Command = Class("Command", {
init: function (specs, description, action, extraInfo) {
specs = Array.concat(specs); // XXX
let expandedSpecs = Command.parseSpecs(specs);
if (!extraInfo)
extraInfo = {};
let parsedSpecs = Command.parseSpecs(specs);
this.specs = specs;
this.shortNames = array(expandedSpecs).map(function (n) n[1]).compact();
this.longNames = expandedSpecs.map(function (n) n[0]);
this.shortNames = array(parsedSpecs).map(function (n) n[1]).compact();
this.longNames = parsedSpecs.map(function (n) n[0]);
this.name = this.longNames[0];
this.names = array(expandedSpecs).flatten();
this.names = array(parsedSpecs).flatten();
this.description = description;
this.action = action;
extraInfo.privateData = Boolean(extraInfo.privateData); // XXX
if (extraInfo)
update(this, extraInfo);
},

View File

@@ -1,4 +1,6 @@
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2009 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2009 by Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
@@ -31,14 +33,12 @@ const Map = Class("Map", {
init: function (modes, keys, description, action, extraInfo) {
modes = Array.concat(modes).map(function (m) isobject(m) ? m.mask : m);
if (!extraInfo)
extraInfo = {};
this.modes = modes;
this.names = keys.map(events.canonicalKeys);
this.action = action;
this.description = description;
if (extraInfo)
update(this, extraInfo);
},

View File

@@ -28,9 +28,6 @@
*/
const Option = Class("Option", {
init: function (names, description, type, defaultValue, extraInfo) {
if (!extraInfo)
extraInfo = {};
this.name = names[0];
this.names = names;
this.type = type;
@@ -39,6 +36,7 @@ const Option = Class("Option", {
if (arguments.length > 3)
this.defaultValue = defaultValue;
if (extraInfo)
update(this, extraInfo);
// add no{option} variant of boolean {option} to this.names
@@ -165,7 +163,8 @@ const Option = Class("Option", {
/**
* @property {value} The option's current value. The option's local value,
* or if no local value is set, this is equal to the (@link #globalValue).
* or if no local value is set, this is equal to the
* (@link #globalValue).
*/
get value() this.get(),
set value(val) this.set(val),