Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
timhub66 committed Sep 30, 2024
2 parents 0918e2f + a6796fc commit 6f20e71
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
7 changes: 7 additions & 0 deletions docs/zh-cn/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

---

### 1.0.0-rc.12

`2024-9-30`

- **Feature**
- 子应用支持 web Component


### 1.0.0-rc.11

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@micro-zoe/micro-app",
"version": "1.0.0-rc.11",
"version": "1.0.0-rc.12",
"description": "A lightweight, efficient and powerful micro front-end framework",
"private": false,
"main": "lib/index.min.js",
Expand Down
9 changes: 9 additions & 0 deletions src/libs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ export function isMicroAppHead(target: unknown): target is HTMLElement {
return isElement(target) && target.tagName.toUpperCase() === 'MICRO-APP-HEAD'
}

export function isWebComponentElement(target: unknown): boolean {
let result = toTypeString(target) === '[object HTMLElement]'
if (result) {
const tagName = (target as HTMLElement).tagName.toUpperCase()
result = result && !tagName.startsWith('MICRO-APP')
}
return result
}

// is ProxyDocument
export function isProxyDocument(target: unknown): target is Document {
return toTypeString(target) === '[object ProxyDocument]'
Expand Down
7 changes: 0 additions & 7 deletions src/sandbox/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {
getPreventSetState,
throttleDeferForIframeAppName,
isAnchorElement,
isImageElement,
isVideoElement,
isAudioElement,
} from '../libs/utils'
import {
appInstanceMap,
Expand Down Expand Up @@ -170,10 +167,6 @@ export function updateElementInfo <T> (node: T, appName: string | null): T {
}
}
}
if (isImageElement(node) || isVideoElement(node) || isAudioElement(node)) {
// @ts-ignore
node.crossOrigin = 'anonymous'
}
rawDefineProperties(node, props)

/**
Expand Down
6 changes: 5 additions & 1 deletion src/sandbox/iframe/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
isUniqueElement,
isInvalidQuerySelectorKey,
throttleDeferForIframeAppName,
isWebComponentElement,
} from '../../libs/utils'
import globalEnv from '../../libs/global_env'
import bindFunctionToRawTarget from '../bind_function'
Expand Down Expand Up @@ -86,7 +87,10 @@ function patchDocumentPrototype (appName: string, microAppWindow: microAppWindow
tagName: string,
options?: ElementCreationOptions,
): HTMLElement {
const element = rawMicroCreateElement.call(this, tagName, options)
let element = rawMicroCreateElement.call(this, tagName, options)
if (isWebComponentElement(element)) {
element = rawMicroCreateElement.call(rawDocument, tagName, options)
}
return updateElementInfo(element, appName)
}

Expand Down

0 comments on commit 6f20e71

Please sign in to comment.