From ce9cfa2d729d3550fc24894e139393d07e3f90b6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 31 Oct 2023 20:13:13 +0100 Subject: [PATCH] Skip the PREFERENCE-branch in `AppOptions.getAll` in official builds Given that this branch is only necessary in development mode and *during* building, but is never actually used in the final viewer-bundles, we can utilize the pre-processor to ignore this code. --- web/app_options.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/app_options.js b/web/app_options.js index b8b592177291b..970b0ba837ed2 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -400,10 +400,13 @@ class AppOptions { for (const name in defaultOptions) { const defaultOption = defaultOptions[name]; if (kind) { - if ((kind & defaultOption.kind) === 0) { + if (!(kind & defaultOption.kind)) { continue; } - if (kind === OptionKind.PREFERENCE) { + if ( + (typeof PDFJSDev === "undefined" || PDFJSDev.test("LIB")) && + kind === OptionKind.PREFERENCE + ) { if (defaultOption.kind & OptionKind.BROWSER) { throw new Error(`Invalid kind for preference: ${name}`); }