Merge pull request #10517 from Snuffleupagus/rm-currentScript-polyfill

[api-minor] Remove the `document.currentScript` polyfill
This commit is contained in:
Tim van der Meij 2019-02-03 15:42:30 +01:00 committed by GitHub
commit 9f9d87c3ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 20 deletions

View File

@ -90,7 +90,8 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
}); });
}) : null; }) : null;
if (!fallbackWorkerSrc && typeof document !== 'undefined') { if (!fallbackWorkerSrc && typeof document === 'object' &&
'currentScript' in document) {
const pdfjsFilePath = document.currentScript && document.currentScript.src; const pdfjsFilePath = document.currentScript && document.currentScript.src;
if (pdfjsFilePath) { if (pdfjsFilePath) {
fallbackWorkerSrc = fallbackWorkerSrc =

View File

@ -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. // Provides support for ChildNode.remove in legacy browsers.
// Support: IE. // Support: IE.
(function checkChildNodeRemove() { (function checkChildNodeRemove() {