From 6078901962062fe807fcb89d70d5c9660163a4ce Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 15 Nov 2014 11:38:43 +0100 Subject: [PATCH] Prevent a "TypeError: pdfViewer is null" when the viewer loads (PR 5413 followup) Currently if you manage to e.g. open the console (with Ctrl+Shift+K) before the viewer is initialized, the following will be printed in the console: `TypeError: pdfViewer is null`. This doesn't cause any actual errors, but nevertheless it seems like something we should avoid. Followup to PR 5413. --- web/viewer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/viewer.js b/web/viewer.js index adbde5862..439fb0106 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -2024,9 +2024,9 @@ window.addEventListener('keydown', function keydown(evt) { if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) { // either CTRL or META key with optional SHIFT. var pdfViewer = PDFViewerApplication.pdfViewer; - var inPresentationMode = - pdfViewer.presentationModeState === PresentationModeState.CHANGING || - pdfViewer.presentationModeState === PresentationModeState.FULLSCREEN; + var inPresentationMode = pdfViewer && + (pdfViewer.presentationModeState === PresentationModeState.CHANGING || + pdfViewer.presentationModeState === PresentationModeState.FULLSCREEN); switch (evt.keyCode) { case 70: // f