Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS15 safari下子应用index.html内联script导致加载失败 #648

Closed
IceEnd opened this issue Jul 27, 2023 · 4 comments
Closed

iOS15 safari下子应用index.html内联script导致加载失败 #648

IceEnd opened this issue Jul 27, 2023 · 4 comments

Comments

@IceEnd
Copy link

IceEnd commented Jul 27, 2023

描述bug

在iOS 15.2 版本左右,如果子应用中使用了内联的 script 标签,wujie处理的时候会报错:TypeError: Attempting to change the getter of an unconfigurable property.

如何复现

  1. 子应用中使用了内联的script标签,比如
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());

    gtag('config', 'xxxxx');
  </script>
  1. 在挂载子应用时,wujie会处理这一段代码,具体定位到 https://github.dev/Tencent/wujie/blob/17179fbca76b23ee9b05eeec88818b65cc1e7daa/packages/wujie-core/src/iframe.ts#L728-L729
// 解决 webpack publicPath 为 auto 无法加载资源的问题
Object.defineProperty(scriptElement, "src", { get: () => src || "" });

而在这个版本的safari下 src 是不可配置的:

{get: function, set: function, enumerable: false, configurable: false}

导致报错:TypeError: Attempting to change the getter of an unconfigurable property.

这里有办法进行解决吗?

@yiludege
Copy link
Collaborator

可以提一个pr 过来,判断一下scriptElement的configurable,再进行这个逻辑处理

@IceEnd
Copy link
Author

IceEnd commented Aug 1, 2023

可以提一个pr 过来,判断一下scriptElement的configurable,再进行这个逻辑处理

麻烦帮忙CR下

@IceEnd
Copy link
Author

IceEnd commented Aug 29, 2023

@yiludege 大佬,帮忙cr一下

@RaHsu
Copy link

RaHsu commented Nov 7, 2023

同遇到这个问题,求快速pr解决一下呢 @yiludege

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants