diff --git a/web/download_manager.js b/web/download_manager.js index 3ac266d66..e7d031c63 100644 --- a/web/download_manager.js +++ b/web/download_manager.js @@ -47,9 +47,7 @@ function download(blobUrl, filename) { * @implements {IDownloadManager} */ class DownloadManager { - constructor() { - this._openBlobUrls = new WeakMap(); - } + #openBlobUrls = new WeakMap(); downloadUrl(url, filename) { if (!createValidAbsoluteUrl(url, "http://example.com")) { @@ -74,10 +72,10 @@ class DownloadManager { const contentType = isPdfData ? "application/pdf" : ""; if (isPdfData) { - let blobUrl = this._openBlobUrls.get(element); + let blobUrl = this.#openBlobUrls.get(element); if (!blobUrl) { blobUrl = URL.createObjectURL(new Blob([data], { type: contentType })); - this._openBlobUrls.set(element, blobUrl); + this.#openBlobUrls.set(element, blobUrl); } let viewerUrl; if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { @@ -101,7 +99,7 @@ class DownloadManager { // Release the `blobUrl`, since opening it failed, and fallback to // downloading the PDF file. URL.revokeObjectURL(blobUrl); - this._openBlobUrls.delete(element); + this.#openBlobUrls.delete(element); } } diff --git a/web/event_utils.js b/web/event_utils.js index 077699598..3ae6910be 100644 --- a/web/event_utils.js +++ b/web/event_utils.js @@ -75,9 +75,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) { * and `off` methods. To raise an event, the `dispatch` method shall be used. */ class EventBus { - constructor() { - this._listeners = Object.create(null); - } + #listeners = Object.create(null); /** * @param {string} eventName @@ -108,7 +106,7 @@ class EventBus { * @param {Object} data */ dispatch(eventName, data) { - const eventListeners = this._listeners[eventName]; + const eventListeners = this.#listeners[eventName]; if (!eventListeners || eventListeners.length === 0) { return; } @@ -139,7 +137,7 @@ class EventBus { * @ignore */ _on(eventName, listener, options = null) { - const eventListeners = (this._listeners[eventName] ||= []); + const eventListeners = (this.#listeners[eventName] ||= []); eventListeners.push({ listener, external: options?.external === true, @@ -151,7 +149,7 @@ class EventBus { * @ignore */ _off(eventName, listener, options = null) { - const eventListeners = this._listeners[eventName]; + const eventListeners = this.#listeners[eventName]; if (!eventListeners) { return; } diff --git a/web/firefoxcom.js b/web/firefoxcom.js index 0e5172b53..a157b282e 100644 --- a/web/firefoxcom.js +++ b/web/firefoxcom.js @@ -100,9 +100,7 @@ class FirefoxCom { } class DownloadManager { - constructor() { - this._openBlobUrls = new WeakMap(); - } + #openBlobUrls = new WeakMap(); downloadUrl(url, filename) { FirefoxCom.request("download", { @@ -132,10 +130,10 @@ class DownloadManager { const contentType = isPdfData ? "application/pdf" : ""; if (isPdfData) { - let blobUrl = this._openBlobUrls.get(element); + let blobUrl = this.#openBlobUrls.get(element); if (!blobUrl) { blobUrl = URL.createObjectURL(new Blob([data], { type: contentType })); - this._openBlobUrls.set(element, blobUrl); + this.#openBlobUrls.set(element, blobUrl); } // Let Firefox's content handler catch the URL and display the PDF. const viewerUrl = blobUrl + "#filename=" + encodeURIComponent(filename); @@ -148,7 +146,7 @@ class DownloadManager { // Release the `blobUrl`, since opening it failed, and fallback to // downloading the PDF file. URL.revokeObjectURL(blobUrl); - this._openBlobUrls.delete(element); + this.#openBlobUrls.delete(element); } }