Skip to content

Commit

Permalink
Merge pull request #1451 from micro-zoe/feat_enhui_fix
Browse files Browse the repository at this point in the history
fix: Fixing the anchor tag
  • Loading branch information
raoenhui authored Nov 22, 2024
2 parents b0f776e + b73ac7a commit 609bfbc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion dev/children/vue2/src/pages/home.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<template>
<div>
<div class='logo-img'></div>
<div id="imageId" class='logo-img'></div>
<!-- <div class='outer-img'></div>
<img src="../assets/logo.png" alt=""> -->
<h3>Vue@{{version}}</h3>
<a href="#imageId">测试a标签瞄点</a>
<HelloWorld msg="Welcome to Your Vue.js App"/>
<div class='msg-title'>{{microDataStr}}</div>
<span class="iconfont">&#xe649;</span>
Expand Down
6 changes: 6 additions & 0 deletions docs/zh-cn/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
- 修订版本号:每周末会进行日常 bugfix 更新。(如果有紧急的 bugfix,则任何时候都可发布)

---
### 1.0.0-rc.14

`2024-11-22`
- **Bug Fix**
- 🐞 修复 子应用a标签href为瞄点 #xxx引起异常。

### 1.0.0-rc.13

`2024-10-16`
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.13",
"version": "1.0.0-rc.14",
"description": "A lightweight, efficient and powerful micro front-end framework",
"private": false,
"main": "lib/index.min.js",
Expand Down
4 changes: 3 additions & 1 deletion src/sandbox/iframe/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ function patchIframeAttribute (url: string, microAppWindow: microAppWindowType):
} else {
if (
((key === 'src' || key === 'srcset') && /^(img|script|video|audio|source|embed)$/i.test(this.tagName)) ||
(key === 'href' && /^(a|link|image)$/i.test(this.tagName))
(key === 'href' && /^(link|image)$/i.test(this.tagName)) ||
// If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
(key === 'href' && /^(a)$/i.test(this.tagName) && !/^#/.test(value))
) {
let _url = url
if (isBrowser && key === 'href' && /^a$/i.test(this.tagName) && isFunction(microApp.options.excludeAssetFilter) && microApp.options.excludeAssetFilter(value)) {
Expand Down
9 changes: 7 additions & 2 deletions src/source/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ function completePathDynamic(app: AppInterface, newChild: Node): void {
if (newChild.hasAttribute('srcset')) {
globalEnv.rawSetAttribute.call(newChild, 'srcset', CompletionPath(newChild.getAttribute('srcset')!, app.url))
}
} else if (/^(a|link|image)$/i.test(newChild.tagName) && newChild.hasAttribute('href')) {
} else if ((/^(link|image)$/i.test(newChild.tagName) && newChild.hasAttribute('href')) ||
// If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
(/^(a)$/i.test(newChild.tagName) && newChild.hasAttribute('href') && !/^#/.test(newChild.getAttribute('href') || ''))
) {
globalEnv.rawSetAttribute.call(newChild, 'href', CompletionPath(newChild.getAttribute('href')!, app.url))
}
}
Expand Down Expand Up @@ -550,7 +553,9 @@ export function patchElementAndDocument(): void {
appInstanceMap.has(appName) &&
(
((key === 'src' || key === 'srcset') && /^(img|script|video|audio|source|embed)$/i.test(this.tagName)) ||
(key === 'href' && /^(a|link|image)$/i.test(this.tagName))
(key === 'href' && /^(link|image)$/i.test(this.tagName)) ||
// If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
(key === 'href' && /^(a)$/i.test(this.tagName) && !/^#/.test(value))
)

) {
Expand Down

0 comments on commit 609bfbc

Please sign in to comment.