1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Limit base-class initialization checks to development and TESTING modes

We have a number of base-classes that are only intended to be extended, but never to be used directly. To help enforce this during development these base-class constructors will check for direct usage, however that code is obviously not needed in the actual builds.

*Note:* This patch reduces the size of the `gulp mozcentral` output by `~2.7` kilo-bytes, which isn't a lot but still cannot hurt.
This commit is contained in:
Jonas Jenwald 2024-08-12 11:59:13 +02:00
parent aa2337f934
commit aebb8534f3
16 changed files with 79 additions and 20 deletions

View file

@ -37,7 +37,10 @@ function parseDocBaseUrl(url) {
class BasePdfManager {
constructor(args) {
if (this.constructor === BasePdfManager) {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
this.constructor === BasePdfManager
) {
unreachable("Cannot initialize BasePdfManager.");
}
this._docBaseUrl = parseDocBaseUrl(args.docBaseUrl);