From ed8b172d12822a0b2a43aad4daa312c962a5a73a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 7 May 2022 15:48:54 +0200 Subject: [PATCH] Stop bundling `PDFViewerApplication.{unbindEvents, unbindWindowEvents}` in MOZCENTRAL builds These methods are completely unused in the Firefox PDF Viewer, and were only added to supplement the `PDFViewerApplication.{bindEvents, bindWindowEvents}`-methods since third-party implementations may apparently need to remove event listeners (see PR 8525). However, in the MOZCENTRAL build that's just dead code and this patch reduces the size of the *built* `web/viewer.js`-file by `~3.5` kB. --- web/app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/app.js b/web/app.js index 532ddb1a0..f0be10f05 100644 --- a/web/app.js +++ b/web/app.js @@ -1952,6 +1952,9 @@ const PDFViewerApplication = { }, unbindEvents() { + if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { + throw new Error("Not implemented: unbindEvents"); + } const { eventBus, _boundEvents } = this; eventBus._off("resize", webViewerResize); @@ -2008,6 +2011,9 @@ const PDFViewerApplication = { }, unbindWindowEvents() { + if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { + throw new Error("Not implemented: unbindWindowEvents"); + } const { _boundEvents } = this; window.removeEventListener("visibilitychange", webViewerVisibilityChange);