Index: lib/prefs.js |
=================================================================== |
--- a/lib/prefs.js |
+++ b/lib/prefs.js |
@@ -45,44 +45,47 @@ |
function defineProperty(key) |
{ |
let value = null; |
- Prefs.__defineGetter__(key, function() |
- { |
- if (value === null) |
+ Object.defineProperty(Prefs, key, { |
+ get: function() |
{ |
- if (key in ext.storage) |
+ if (value === null) |
{ |
- try |
+ if (key in ext.storage) |
{ |
- value = JSON.parse(ext.storage[key]); |
+ try |
+ { |
+ value = JSON.parse(ext.storage[key]); |
+ } |
+ catch(e) |
+ { |
+ Cu.reportError(e); |
+ } |
} |
- catch(e) |
- { |
- Cu.reportError(e); |
- } |
+ |
+ if (value === null) |
+ value = JSON.parse(JSON.stringify(defaults[key])); |
} |
+ return value; |
+ }, |
+ set: function(newValue) |
+ { |
+ if (typeof newValue != typeof defaults[key]) |
+ throw new Error("Attempt to change preference type"); |
- if (value === null) |
- value = JSON.parse(JSON.stringify(defaults[key])); |
- } |
- return value; |
- }); |
- Prefs.__defineSetter__(key, function(newValue) |
- { |
- if (typeof newValue != typeof defaults[key]) |
- throw new Error("Attempt to change preference type"); |
+ let stringified = JSON.stringify(newValue); |
+ if (stringified != JSON.stringify(defaults[key])) |
+ ext.storage[key] = stringified; |
+ else |
+ delete ext.storage[key]; |
- let stringified = JSON.stringify(newValue); |
- if (stringified != JSON.stringify(defaults[key])) |
- ext.storage[key] = stringified; |
- else |
- delete ext.storage[key]; |
+ value = newValue; |
- value = newValue; |
+ for (let listener of listeners) |
+ listener(key); |
- for (let listener of listeners) |
- listener(key); |
- |
- return value; |
+ return value; |
+ }, |
+ enumerable: true |
}); |
} |