Skip to content

Commit

Permalink
🐛 should not change currentScript if it not configurable (#1470)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuitos committed May 25, 2021
1 parent fd289f2 commit ad9a59c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/sandbox/patchers/dynamicAppend/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

1 comment on commit ad9a59c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for qiankun ready!

✅ Preview
https://qiankun-a3fo2vbne-umijs.vercel.app

Built with commit ad9a59c.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.