Skip to content

Commit

Permalink
fix: script object with crossorigin (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuitos authored Aug 18, 2023
1 parent 47d3c06 commit ada135b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export function execScripts(entry, scripts, proxy = window, opts = {}) {
noteGlobalProps(strictGlobal ? proxy : window);

try {
// bind window.proxy to change `this` reference in script
geval(scriptSrc, inlineScript);
const exports = proxy[getGlobalProp(strictGlobal ? proxy : window)] || {};
resolve(exports);
Expand All @@ -204,8 +203,11 @@ export function execScripts(entry, scripts, proxy = window, opts = {}) {
} else {
if (typeof inlineScript === 'string') {
try {
// bind window.proxy to change `this` reference in script
geval(scriptSrc, inlineScript);
if (scriptSrc?.src) {
geval(scriptSrc.src, inlineScript);
} else {
geval(scriptSrc, inlineScript);
}
} catch (e) {
// consistent with browser behavior, any independent script evaluation error should not block the others
throwNonBlockingError(e, `[import-html-entry]: error occurs while executing normal script ${scriptSrc}`);
Expand Down

0 comments on commit ada135b

Please sign in to comment.