fix: 将 font 样式挂载到最外层 document.head 以支持嵌套子应用 - #1092
Merged
Merged
Conversation
问题: - 子应用中的 @font-face 样式被挂载到 shadowRoot.host - 嵌套子应用场景下,shadowRoot.host 仍在父应用的 shadowRoot 内 - 导致 font 样式无法生效 解决方案: - 新增 inject.fontStyleSheetContainer 指向最外层 document.head 的容器 - 嵌套子应用通过 window.__WUJIE.inject 自动继承该容器引用 - font 样式统一挂载到该容器,确保所有子应用都能正确加载字体 修改: - constant.ts: 新增 WUJIE_FONT_STYLE_CONTAINER_ATTR 常量 - sandbox.ts: - 新增 fontStyleSheetElements 数组记录 font 样式元素 - 新增 createFontStyleSheetContainer() 方法创建/获取容器 - 新增 clearFontStyleSheets() 方法用于 destroy 时清理 - patchCssRules() 中将 font 样式挂载到 fontStyleSheetContainer - effect.ts: handleStylesheetElementPatch() 中同样使用 fontStyleSheetContainer
yiludege
force-pushed
the
fix/nested-font-style
branch
from
June 9, 2026 09:48
89f0401 to
98bc4f9
Compare
5 tasks
yiludege
added a commit
that referenced
this pull request
Jun 15, 2026
* Revert "fix: 将 font 样式挂载到最外层 document.head 以支持嵌套子应用 (#1092)" This reverts commit 2ed612f. * fix: 将 font 样式挂载到最外层 document.head 以支持嵌套子应用 在 revert #1092 错误合入后重新应用本修复。原 PR 误将 monorepo 压扁为单包结构, 本提交仅修改 wujie-core 三个源文件,并保留 #1093 的 CSS placeholder 逻辑。 Fixes #845 Fixes #620 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
yiludege
added a commit
that referenced
this pull request
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
子应用中的 @font-face 样式被挂载到
shadowRoot.host,在嵌套子应用场景下,shadowRoot.host仍在父应用的 shadowRoot 内部,导致 font 样式无法生效。相关 issue:
解决方案
inject.fontStyleSheetContainer指向最外层document.head的容器window.__WUJIE.inject自动继承该容器引用修改文件
constant.ts
WUJIE_FONT_STYLE_CONTAINER_ATTR常量sandbox.ts
fontStyleSheetElements数组记录 font 样式元素createFontStyleSheetContainer()方法创建/获取容器clearFontStyleSheets()方法用于 destroy 时清理patchCssRules()中将 font 样式挂载到fontStyleSheetContainereffect.ts
handleStylesheetElementPatch()中同样使用fontStyleSheetContainer测试
Fixes #845
Fixes #620