Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/prefs.js

Issue 5462707926990848: Issue 1434 - Removed remaining non-standard JavaScript code from buildtools (Closed)
Patch Set: Make Prefs enumerable again Created May 6, 2015, 11:06 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/hooks.js ('K') | « lib/keySelector.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/prefs.js
===================================================================
--- a/lib/prefs.js
+++ b/lib/prefs.js
@@ -44,7 +44,7 @@
try
{
branch.QueryInterface(Ci.nsIPrefBranch2).addObserver("", Prefs, true);
- onShutdown.add(function() branch.removeObserver("", Prefs));
+ onShutdown.add(() => branch.removeObserver("", Prefs));
}
catch (e)
{
@@ -70,29 +70,32 @@
Cu.reportError(e);
}
};
- Prefs.__defineGetter__(name, function() value);
- Prefs.__defineSetter__(name, function(newValue)
- {
- if (value == newValue)
+ Object.defineProperty(Prefs, name, {
+ get: () => value,
+ set: function(newValue)
+ {
+ if (value == newValue)
+ return value;
+
+ try
+ {
+ ignorePrefChanges = true;
+ writeFunc(branch, name, newValue);
+ value = newValue;
+ Services.prefs.savePrefFile(null);
+ triggerListeners(name);
+ }
+ catch(e)
+ {
+ Cu.reportError(e);
+ }
+ finally
+ {
+ ignorePrefChanges = false;
+ }
return value;
-
- try
- {
- ignorePrefChanges = true;
- writeFunc(branch, name, newValue);
- value = newValue;
- Services.prefs.savePrefFile(null);
- triggerListeners(name);
- }
- catch(e)
- {
- Cu.reportError(e);
- }
- finally
- {
- ignorePrefChanges = false;
- }
- return value;
+ },
+ enumerable: true
});
Prefs["_update_" + name]();
}
« lib/hooks.js ('K') | « lib/keySelector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld