From 4eaa058c168cfbf8548caddb574a4889e8576efd Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 31 Oct 2020 09:54:00 +0100 Subject: [PATCH] Add early returns to a couple of `PDFLinkService` methods, when there's no active PDF document All of these methods will, in one way or another, cause e.g. scrolling or zooming to occur and consequently they don't really make sense unless there's an active PDF document. Especially since all of these methods end up calling into a `BaseViewer`-instance, which already contains similar early returns in essentially all of it's methods and setters. --- web/pdf_link_service.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/pdf_link_service.js b/web/pdf_link_service.js index dd57fa701..9809aa073 100644 --- a/web/pdf_link_service.js +++ b/web/pdf_link_service.js @@ -182,6 +182,9 @@ class PDFLinkService { * @param {string|Array} dest - The named, or explicit, PDF destination. */ async goToDestination(dest) { + if (!this.pdfDocument) { + return; + } let namedDest, explicitDest; if (typeof dest === "string") { namedDest = dest; @@ -206,6 +209,9 @@ class PDFLinkService { * @param {number} pageNumber - The page number. */ goToPage(pageNumber) { + if (!this.pdfDocument) { + return; + } if ( !( Number.isInteger(pageNumber) && @@ -261,6 +267,9 @@ class PDFLinkService { * @param {string} hash */ setHash(hash) { + if (!this.pdfDocument) { + return; + } let pageNumber, dest; if (hash.includes("=")) { const params = parseQueryString(hash);