Skip to content
Open
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
9 changes: 6 additions & 3 deletions src/source/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,15 @@ export function patchElementAndDocument(): void {
*/
function getElementQueryTarget(targetNode: Node): Node | null {
const currentAppName = getIframeCurrentAppName() || getCurrentAppName()
if ((targetNode === document.body || targetNode === document.head) && currentAppName) {
// 使用 rawDocument 避免触发被代理的 document.body/head getter,防止循环引用
const rawBody = globalEnv.rawDocument.body
const rawHead = globalEnv.rawDocument.head
if ((targetNode === rawBody || targetNode === rawHead) && currentAppName) {
const app = appInstanceMap.get(currentAppName)
if (app?.container) {
if (targetNode === document.body) {
if (targetNode === rawBody) {
return app.querySelector<HTMLElement>('micro-app-body')
} else if (targetNode === document.head) {
} else if (targetNode === rawHead) {
return app.querySelector<HTMLElement>('micro-app-head')
}
}
Expand Down