1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 06:38:07 +02:00

Merge pull request #18495 from Snuffleupagus/AppOptions-setAll-EVENT_DISPATCH

Consistently dispatch events, if needed, when setting AppOptions
This commit is contained in:
Jonas Jenwald 2024-07-27 10:55:58 +02:00 committed by GitHub
commit 3a21f03b07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -571,18 +571,7 @@ class AppOptions {
}
static set(name, value) {
const defaultOpt = defaultOptions[name];
if (
!defaultOpt ||
!(
typeof value === typeof defaultOpt.value ||
Type[(typeof value).toUpperCase()] & defaultOpt.type
)
) {
return;
}
userOptions.set(name, value);
this.setAll({ [name]: value });
}
static setAll(options, prefs = false) {
@ -601,15 +590,16 @@ class AppOptions {
) {
continue;
}
if (prefs) {
const { kind } = defaultOpt;
const { kind } = defaultOpt;
if (!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) {
continue;
}
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
(events ||= new Map()).set(name, userOpt);
}
if (
prefs &&
!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)
) {
continue;
}
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
(events ||= new Map()).set(name, userOpt);
}
userOptions.set(name, userOpt);
}