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