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

fix: appendChildOrInsertBefore effect ignore css error #643

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/wujie-core/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,18 @@ function rewriteAppendOrInsertChild(opts: {
// 处理 ignore 样式
const rawAttrs = parseTagAttributes(element.outerHTML);
if (ignore && src) {
const stylesheetElement = iframeDocument.createElement("link");
const attrs = {
...rawAttrs,
type: "text/css",
rel: "stylesheet",
href: src,
};
setAttrsToElement(stylesheetElement, attrs);
rawDOMAppendOrInsertBefore.call(this, stylesheetElement, refChild);
manualInvokeElementEvent(element, "load");
// const stylesheetElement = iframeDocument.createElement("link");
// const attrs = {
// ...rawAttrs,
// type: "text/css",
// rel: "stylesheet",
// href: src,
// };
// setAttrsToElement(stylesheetElement, attrs);
// rawDOMAppendOrInsertBefore.call(this, stylesheetElement, refChild);
// manualInvokeElementEvent(element, "load");
// 忽略的元素应该直接把对应元素插入,而不是用新的 link 标签进行替代插入,保证 element 的上下文正常
rawDOMAppendOrInsertBefore.call(this, element, refChild);
} else {
// 记录js插入样式,子应用重新激活时恢复
const stylesheetElement = iframeDocument.createElement("style");
Expand Down