code review for #292

This commit is contained in:
gorhill 2015-06-04 16:50:46 -04:00
parent 987a8d2b64
commit 48264e1fd7
1 changed files with 10 additions and 5 deletions

View File

@ -116,20 +116,25 @@ vAPI.browserSettings = {
}, },
clear: function(branch, setting) { clear: function(branch, setting) {
var value = this.originalValues[branch + '.' + setting]; var key = branch + '.' + setting;
if ( // Value was not overriden -- nothing to restore
value === undefined && if ( this.originalValues.hasOwnProperty(key) === false ) {
this.originalValues.hasOwnProperty(branch + '.' + setting) return;
) { }
var value = this.originalValues[key];
// Original value was a default one
if ( value === undefined ) {
try { try {
Services.prefs.getBranch(branch + '.').clearUserPref(setting); Services.prefs.getBranch(branch + '.').clearUserPref(setting);
} catch (ex) { } catch (ex) {
} }
return; return;
} }
// Current value is same as original
if ( this.getBool(branch, setting) === value ) { if ( this.getBool(branch, setting) === value ) {
return; return;
} }
// Reset to original value
try { try {
Services.prefs.getBranch(branch + '.').setBoolPref(setting, value); Services.prefs.getBranch(branch + '.').setBoolPref(setting, value);
} catch (ex) { } catch (ex) {