From 2c74c526c004d229ea0a2895d33db0a211164fcb Mon Sep 17 00:00:00 2001 From: Francis Date: Fri, 1 Aug 2025 16:49:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20heroUI=20popover=20?= =?UTF-8?q?=E5=BC=B9=E5=B1=82=E5=81=8F=E7=A7=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sandbox/adapter.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sandbox/adapter.ts b/src/sandbox/adapter.ts index 72938c57..1ccb4849 100644 --- a/src/sandbox/adapter.ts +++ b/src/sandbox/adapter.ts @@ -145,7 +145,7 @@ export function updateElementInfo (node: T, appName: string | null): T { * TODO: * 1. 测试baseURI和ownerDocument在with沙箱中是否正确 * 经过验证with沙箱不能重写ownerDocument,否则react点击事件会触发两次 - */ + */ const props: {[kye:string]:any} = { __MICRO_APP_NAME__: { configurable: true, @@ -191,6 +191,8 @@ export function updateElementInfo (node: T, appName: string | null): T { */ if (isIframeSandbox(appName)) { const proxyWindow = appInstanceMap.get(appName)?.sandBox?.proxyWindow + const rawGetBoundingClientRect = (node as any).getBoundingClientRect + if (proxyWindow) { rawDefineProperties(node, { baseURI: { @@ -215,6 +217,17 @@ export function updateElementInfo (node: T, appName: string | null): T { return proxyWindow.document } }, + getBoundingClientRect: { + configurable: true, + enumerable: true, + value: function(this: Element) { + if (isMicroAppBody(this)) { + const mainAppBody = globalEnv.rawDocument.body + return mainAppBody.getBoundingClientRect() + } + return rawGetBoundingClientRect.call(this) + }, + }, }) } }