Skip to content

Commit

Permalink
Merge pull request #651 from IceEnd/bugfix/648
Browse files Browse the repository at this point in the history
fix: 兼容部分浏览器script src不可配置
  • Loading branch information
sunyuis committed Nov 8, 2023
2 parents 70ae900 + 3eab5cf commit eae19b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/wujie-core/src/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,12 @@ export function insertScriptToIframe(
window.__WUJIE.proxyLocation,
);`;
}
// 解决 webpack publicPath 为 auto 无法加载资源的问题
Object.defineProperty(scriptElement, "src", { get: () => src || "" });
const descriptor = Object.getOwnPropertyDescriptor(scriptElement, "src");
// 部分浏览器 src 不可配置
if (!descriptor?.configurable) {
// 解决 webpack publicPath 为 auto 无法加载资源的问题
Object.defineProperty(scriptElement, "src", { get: () => src || "" });
}
} else {
src && scriptElement.setAttribute("src", src);
crossorigin && scriptElement.setAttribute("crossorigin", crossoriginType);
Expand Down

0 comments on commit eae19b7

Please sign in to comment.