Bug 963207 - fixing SettingCache to run callback on setting change observed. r=eeejay

---
 accessible/src/jsat/Utils.jsm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
This commit is contained in:
Yura Zenevich 2014-01-23 16:44:13 -05:00
parent 5d91316dcf
commit 936c6f0368

View File

@ -778,7 +778,7 @@ PrefCache.prototype = {
this.SettingCache = function SettingCache(aName, aCallback, aOptions = {}) {
this.value = aOptions.defaultValue;
let runCallback = () => {
if (aCallback && aOptions.callbackNow) {
if (aCallback) {
aCallback(aName, this.value);
if (aOptions.callbackOnce) {
runCallback = () => {};
@ -788,7 +788,9 @@ this.SettingCache = function SettingCache(aName, aCallback, aOptions = {}) {
let settings = Utils.win.navigator.mozSettings;
if (!settings) {
runCallback();
if (aOptions.callbackNow) {
runCallback();
}
return;
}
@ -798,7 +800,9 @@ this.SettingCache = function SettingCache(aName, aCallback, aOptions = {}) {
req.addEventListener('success', () => {
this.value = req.result[aName] == undefined ? aOptions.defaultValue : req.result[aName];
runCallback();
if (aOptions.callbackNow) {
runCallback();
}
});
settings.addObserver(aName,