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: Replaced some more function expressions Created April 1, 2015, 2:26 p.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
« no previous file with comments | « 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
@@ -36,7 +36,7 @@
try
{
branch.QueryInterface(Ci.nsIPrefBranch2).addObserver("", Prefs, true);
- onShutdown.add(function() branch.removeObserver("", Prefs));
+ onShutdown.add(() => branch.removeObserver("", Prefs));
}
catch (e)
{
@@ -62,29 +62,31 @@
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;
});
Prefs["_update_" + name]();
}
« no previous file with comments | « lib/keySelector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld