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
15 changes: 14 additions & 1 deletion src/sandbox/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function updateElementInfo <T> (node: T, appName: string | null): T {
* TODO:
* 1. 测试baseURI和ownerDocument在with沙箱中是否正确
* 经过验证with沙箱不能重写ownerDocument,否则react点击事件会触发两次
*/
*/
const props: {[kye:string]:any} = {
__MICRO_APP_NAME__: {
configurable: true,
Expand Down Expand Up @@ -191,6 +191,8 @@ export function updateElementInfo <T> (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: {
Expand All @@ -215,6 +217,17 @@ export function updateElementInfo <T> (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)
},
},
})
}
}
Expand Down