mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
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:
parent
5d91316dcf
commit
936c6f0368
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user