🐛 should not change currentScript if it not configurable (#1470)

This commit is contained in:
Kuitos 2021-05-25 17:49:26 +08:00 committed by GitHub
parent 4f84024e6f
commit c2a7590666

View File

@ -219,12 +219,18 @@ function getOverwrittenAppendChildOrInsertBefore(opts: {
fetch, fetch,
strictGlobal, strictGlobal,
beforeExec: () => { beforeExec: () => {
const isCurrentScriptConfigurable = () => {
const descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript');
return !descriptor || descriptor.configurable;
};
if (isCurrentScriptConfigurable()) {
Object.defineProperty(document, 'currentScript', { Object.defineProperty(document, 'currentScript', {
get(): any { get(): any {
return element; return element;
}, },
configurable: true, configurable: true,
}); });
}
}, },
success: () => { success: () => {
manualInvokeElementOnLoad(element); manualInvokeElementOnLoad(element);