fix getOptions

This commit is contained in:
nightwing 2013-05-11 13:04:59 +04:00
commit 441dfbad30
2 changed files with 14 additions and 8 deletions

View file

@ -190,19 +190,25 @@ var optionsProvider = {
this.setOption(key, optList[key]); this.setOption(key, optList[key]);
}, this); }, this);
}, },
getOptions: function(a) { getOptions: function(optionNames) {
var b = {}; var result = {};
Object.keys(a).forEach(function(key) { if (!optionNames) {
b[key] = this.getOption(key); optionNames = Object.keys(this.$options);
} else if (!Array.isArray(optionNames)) {
result = optionNames;
optionNames = Object.keys(result);
}
optionNames.forEach(function(key) {
result[key] = this.getOption(key);
}, this); }, this);
return b; return result;
}, },
setOption: function(name, value) { setOption: function(name, value) {
if (this["$" + name] === value) if (this["$" + name] === value)
return; return;
var opt = this.$options[name]; var opt = this.$options[name];
if (!opt) if (!opt)
return undefined; return false;
if (opt.forwardTo) if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value); return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
@ -214,7 +220,7 @@ var optionsProvider = {
getOption: function(name) { getOption: function(name) {
var opt = this.$options[name]; var opt = this.$options[name];
if (!opt) if (!opt)
return undefined; return false;
if (opt.forwardTo) if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].getOption(name); return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
return opt && opt.get ? opt.get.call(this) : this["$" + name]; return opt && opt.get ? opt.get.call(this) : this["$" + name];

View file

@ -90,7 +90,7 @@ var supportedModes = {
Makefile: ["^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"], Makefile: ["^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"],
Markdown: ["md|markdown"], Markdown: ["md|markdown"],
MUSHCode: ["mc|mush"], MUSHCode: ["mc|mush"],
ObjectiveC: ["m"], ObjectiveC: ["m|mm"],
OCaml: ["ml|mli"], OCaml: ["ml|mli"],
Pascal: ["pas|p"], Pascal: ["pas|p"],
Perl: ["pl|pm"], Perl: ["pl|pm"],