Skip to content

Commit

Permalink
Merge pull request #10517 from Snuffleupagus/rm-currentScript-polyfill
Browse files Browse the repository at this point in the history
[api-minor] Remove the `document.currentScript` polyfill
  • Loading branch information
timvandermeij authored Feb 3, 2019
2 parents 80495e6 + 614e502 commit 9f9d87c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
19 changes: 0 additions & 19 deletions src/shared/compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 9f9d87c

Please sign in to comment.