mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Move the "updatedPreference" event listener registration
This patch fixes a situation that'll probably never happen, but nonetheless seems like something that we should address. Currently the "updatedPreference" listener isn't registered *until after* the preferences have been read and initialized, which leaves a very short window of time where a preference change could theoretically be skipped.
This commit is contained in:
parent
db9115625b
commit
9e352a8bad
1 changed files with 5 additions and 7 deletions
|
@ -67,16 +67,13 @@ class BasePreferences {
|
|||
typeof prefVal === typeof val ? prefVal : val;
|
||||
}
|
||||
AppOptions.setAll(options, /* init = */ true);
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
window.addEventListener("updatedPreference", evt => {
|
||||
this.#updatePref(evt.detail);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
window.addEventListener("updatedPreference", evt => {
|
||||
this.#updatePref(evt.detail);
|
||||
});
|
||||
this.eventBus = null;
|
||||
}
|
||||
}
|
||||
|
@ -101,10 +98,11 @@ class BasePreferences {
|
|||
throw new Error("Not implemented: _readFromStorage");
|
||||
}
|
||||
|
||||
#updatePref({ name, value }) {
|
||||
async #updatePref({ name, value }) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error("Not implemented: #updatePref");
|
||||
}
|
||||
await this.#initializedPromise;
|
||||
|
||||
if (name in this.#browserDefaults) {
|
||||
if (typeof value !== typeof this.#browserDefaults[name]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue