diff --git a/src/display/api.js b/src/display/api.js index eb4089276..811a2fe61 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -90,7 +90,8 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) { }); }) : null; - if (!fallbackWorkerSrc && typeof document !== 'undefined') { + if (!fallbackWorkerSrc && typeof document === 'object' && + 'currentScript' in document) { const pdfjsFilePath = document.currentScript && document.currentScript.src; if (pdfjsFilePath) { fallbackWorkerSrc = diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index 13122af13..2efb4d1ec 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -54,25 +54,6 @@ const hasDOM = typeof window === 'object' && typeof document === 'object'; }; })(); -// Provides document.currentScript support -// Support: IE, Chrome<29. -(function checkCurrentScript() { - if (!hasDOM) { - return; - } - if ('currentScript' in document) { - return; - } - Object.defineProperty(document, 'currentScript', { - get() { - var scripts = document.getElementsByTagName('script'); - return scripts[scripts.length - 1]; - }, - enumerable: true, - configurable: true, - }); -})(); - // Provides support for ChildNode.remove in legacy browsers. // Support: IE. (function checkChildNodeRemove() {