summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-02-26 10:38:48 -0800
committerAlex Yatskov <alex@foosoft.net>2017-02-26 10:38:48 -0800
commit6b7e094041142b02d83ab5d11acf30565d46ee6c (patch)
treecdf37f8d39f10aa2a75a467226d84fbf66a97491 /ext/bg/js
parent55dd9b1e6b06401e5a5f523fce1f3d6c1db4d9da (diff)
fix options versioning code, update usage guide
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/options.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 127f0421..7a47c702 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -51,7 +51,7 @@ function optionsSetDefaults(options) {
const combine = (target, source) => {
for (const key in source) {
- if (!(key in target)) {
+ if (!target.hasOwnProperty(key)) {
target[key] = source[key];
}
}
@@ -69,9 +69,6 @@ function optionsSetDefaults(options) {
function optionsVersion(options) {
- optionsSetDefaults(options);
- options.version = options.version || 0;
-
const fixups = [
() => {
const copy = (targetDict, targetKey, sourceDict, sourceKey) => {
@@ -125,10 +122,13 @@ function optionsVersion(options) {
}
];
- if (options.version < fixups.length) {
- fixups[options.version]();
- ++options.version;
- optionsVersion(options);
+ optionsSetDefaults(options);
+ if (!options.hasOwnProperty('version')) {
+ options.version = fixups.length;
+ }
+
+ while (options.version < fixups.length) {
+ fixups[options.version++]();
}
return options;