🐛 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,
strictGlobal,
beforeExec: () => {
Object.defineProperty(document, 'currentScript', {
get(): any {
return element;
},
configurable: true,
});
const isCurrentScriptConfigurable = () => {
const descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript');
return !descriptor || descriptor.configurable;
};
if (isCurrentScriptConfigurable()) {
Object.defineProperty(document, 'currentScript', {
get(): any {
return element;
},
configurable: true,
});
}
},
success: () => {
manualInvokeElementOnLoad(element);