Skip to content

Commit 8eb8ccb

Browse files
committed
Merge branch 'dev'
2 parents f0bec96 + 90e691b commit 8eb8ccb

File tree

7 files changed

+2921
-3197
lines changed

7 files changed

+2921
-3197
lines changed

docs/zh-cn/advanced.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,26 @@ microApp.start({
7272
})
7373
```
7474

75-
// 配置所有子应用 a 标签的 href 自动补齐方式
76-
aHrefResolver: (hrefValue: string, appName: string, appUrl: string) => {
77-
return 'https://www.abc.com/'+ hrefValue
78-
}
79-
80-
81-
8275
## 4、aHrefResolver: 自定义处理所有子应用 a 标签的 href 拼接方式
83-
8476
```js
8577
import microApp from '@micro-zoe/micro-app'
8678

8779
microApp.start({
80+
// 配置所有子应用 a 标签的 href 自动补齐方式
8881
aHrefResolver: (hrefValue: string, appName: string, appUrl: string) => {
8982
return 'https://www.abc.com/'+ hrefValue
9083
}
9184
})
9285
```
9386

87+
## escapeIframeWindowEvents : iframe 模式 逃逸沙盒的window事件
88+
```js
89+
import microApp from '@micro-zoe/micro-app'
90+
91+
microApp.start({
92+
// 子应用的
93+
escapeIframeWindowEvents: ['message']
94+
})
95+
```
96+
9497

docs/zh-cn/changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
- 修订版本号:每周末会进行日常 bugfix 更新。(如果有紧急的 bugfix,则任何时候都可发布)
88

99
---
10+
### 1.0.0-rc.25
1011

11-
12+
`2025-05-23`
13+
- **Feature**
14+
- 支持escapeIframeWindowEvents : iframe 模式 逃逸沙盒的window事件。
15+
- **Bug Fix**
16+
- 🐞 修复 子应用样式加载异常,[issue 1553](https://github.com/jd-opensource/micro-app/issues/1553)
17+
- 🐞 修复 当开启样式隔离时子应用属性选择器样式错误,[issue 1573](https://github.com/jd-opensource/micro-app/issues/1573)
1218
### 1.0.0-rc.24
1319

1420
`2025-03-19`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@micro-zoe/micro-app",
3-
"version": "1.0.0-rc.24",
3+
"version": "1.0.0-rc.25",
44
"description": "A lightweight, efficient and powerful micro front-end framework",
55
"private": false,
66
"main": "lib/index.min.js",

src/sandbox/iframe/window.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
escape2RawWindowRegExpKeys,
2626
} from './special_key'
2727
import WorkerProxy from '../../proxies/worker'
28+
import microApp from '../../micro_app'
2829

2930
/**
3031
* patch window of child app
@@ -234,7 +235,12 @@ function patchWindowEffect (microAppWindow: microAppWindowType): CommonEffectHoo
234235
* TODO: SCOPE_WINDOW_EVENT_OF_IFRAME的事件非常少,有可能导致问题
235236
* 1、一些未知的需要绑定到iframe的事件被错误的绑定到原生window上
236237
*/
237-
return SCOPE_WINDOW_EVENT_OF_IFRAME.includes(type) ? microAppWindow : rawWindow
238+
let escapeSandboxEvent: Array<string> = []
239+
if (Array.isArray(microApp?.options?.escapeIframeWindowEvents)) {
240+
escapeSandboxEvent = microApp?.options?.escapeIframeWindowEvents
241+
}
242+
const scopeWindowEvent = SCOPE_WINDOW_EVENT_OF_IFRAME.filter(item => !escapeSandboxEvent.includes(item))
243+
return scopeWindowEvent.includes(type) ? microAppWindow : rawWindow
238244
}
239245

240246
// TODO: listener 是否需要绑定microAppWindow,否则函数中的this指向原生window

src/sandbox/scoped_css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ class CSSParser {
108108
* should be ==> micro-app[name=xxx] :where(.a, .b, .c) a {}
109109
*/
110110
const attributeValues: {[key: string]: any} = {}
111-
const matchRes = m[0].replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g, (match, p1, p2) => {
112-
const mock = `__mock_${p1}Value__`
111+
const matchRes = m[0].replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g, (match, p1, p2, offset) => {
112+
const mock = `__mock_${p1}_${offset}Value__`
113113
attributeValues[mock] = p2
114114
return match.replace(p2, mock)
115115
})

typings/global.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ declare module '@micro-app/types' {
369369
getRootElementParentNode?: (node: Node, appName: AppName) => void
370370
customProxyDocumentProps?: Map<string | number | symbol, (value: unknown) => void>
371371
aHrefResolver?: (hrefValue: string, appName: string, appUrl: string) => string
372-
inheritBaseBody?:boolean
372+
inheritBaseBody?:boolean,
373+
escapeIframeWindowEvents? : Array<string>,
373374
}
374375

375376
// MicroApp config

0 commit comments

Comments
 (0)