Skip to content

Commit 57c661c

Browse files
committed
Merge remote-tracking branch 'origin/dev' into feat_enhui_fix
2 parents 8d03442 + 1314b18 commit 57c661c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

docs/zh-cn/advanced.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,12 @@ microApp.start({
102102
disableIframeRootDocument: true
103103
})
104104
```
105+
## 7、excludeRewriteIframeConstructor : iframe模式下排除对指定构造函数的Symbol.hasInstance属性重写
106+
```js
107+
import microApp from '@micro-zoe/micro-app'
105108

109+
microApp.start({
110+
// iframe模式下,不对事件对象的原型判断进行代理
111+
excludeRewriteIframeConstructor: ['EventTarget']
112+
})
113+
```

src/sandbox/iframe/window.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ function patchWindowProperty (
9494
* 4. native url instanceof iframe window.URL
9595
* ...
9696
*/
97-
if (isConstructor(microAppWindow[key]) && key in rawWindow && !UN_PROXY_INSTANCEOF_KEYS.includes(key)) {
97+
if (
98+
isConstructor(microAppWindow[key]) &&
99+
key in rawWindow &&
100+
!UN_PROXY_INSTANCEOF_KEYS.includes(key) &&
101+
!microApp.options.excludeRewriteIframeConstructor?.includes(key)
102+
) {
98103
rawDefineProperty(microAppWindow[key], Symbol.hasInstance, {
99104
configurable: true,
100105
enumerable: false,

typings/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ declare module '@micro-app/types' {
372372
inheritBaseBody?:boolean,
373373
escapeIframeWindowEvents? : Array<string>,
374374
disableIframeRootDocument?: boolean,
375+
excludeRewriteIframeConstructor?: string[]
375376
}
376377

377378
// MicroApp config

0 commit comments

Comments
 (0)