Skip to content

Commit

Permalink
fix: 修复 子应用 html 上的属性会被丢失的问题(#908) (#909)
Browse files Browse the repository at this point in the history
Co-authored-by: huazhilin <[email protected]>
  • Loading branch information
J10240221 and huazhilin authored Nov 24, 2024
1 parent 9733864 commit e2cf327
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/wujie-core/src/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ function renderTemplateToHtml(iframeWindow: Window, template: string): HTMLHtmlE
const sandbox = iframeWindow.__WUJIE;
const { head, body, alive, execFlag } = sandbox;
const document = iframeWindow.document;
let html = document.createElement("html");
html.innerHTML = template;
const parser = new DOMParser();
const parsedDocument = parser.parseFromString(template, "text/html");

// 无论 template 是否包含html,documentElement 必然是 HTMLHtmlElement
let html = parsedDocument.documentElement as HTMLHtmlElement;
// 组件多次渲染,head和body必须一直使用同一个来应对被缓存的场景
if (!alive && execFlag) {
html = replaceHeadAndBody(html, head, body);
Expand Down

0 comments on commit e2cf327

Please sign in to comment.