From 3aeef8402bb36dd3d1d5cddc79d85d4b65aaf832 Mon Sep 17 00:00:00 2001 From: River Lune Date: Sat, 11 Mar 2017 07:58:56 -0800 Subject: [PATCH] Changing the order of logical conditions to prefer 'window' in the case where webpack is not used. Updating brace style. Updating to throw new error vs. throwing a string. --- web/pdfjs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/pdfjs.js b/web/pdfjs.js index 8e5d642da..00532376f 100644 --- a/web/pdfjs.js +++ b/web/pdfjs.js @@ -21,10 +21,12 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) { var pdfjsLib; // The if below protected by __pdfjsdev_webpack__ check from webpack parsing. if (typeof __pdfjsdev_webpack__ === 'undefined') { - if (typeof require === 'function') { - pdfjsLib = require('../build/pdf.js'); // using a bundler to pull the core + if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) { + pdfjsLib = window['pdfjs-dist/build/pdf']; + } else if (typeof require === 'function') { + pdfjsLib = require('../build/pdf.js'); } else { - pdfjsLib = window['pdfjs-dist/build/pdf']; // loaded via html script tag + throw new Error('Neither `require` nor `window` found'); } } module.exports = pdfjsLib;