Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/holy-two/anchor-proxy
透過 WebComponent 對所有的 a 標簽進行代理事件及攔截
https://github.com/holy-two/anchor-proxy
event-delegation webcomponents
Last synced: about 1 month ago
JSON representation
透過 WebComponent 對所有的 a 標簽進行代理事件及攔截
- Host: GitHub
- URL: https://github.com/holy-two/anchor-proxy
- Owner: holy-two
- License: mit
- Created: 2024-03-04T05:27:41.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-07-27T14:08:54.000Z (4 months ago)
- Last Synced: 2024-10-02T06:44:24.446Z (about 2 months ago)
- Topics: event-delegation, webcomponents
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@holy-two/anchor-proxy
- Size: 105 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# @holy-two/anchor-proxy
透過 WebComponent 封裝的一個對所有的 `a` 標簽進行代理事件及攔截的功能
## 安裝
```bash
pnpm i @holy-two/anchor-proxy
```## 基本
```html
import "@holy-two/anchor-proxy"
const ap = document.createElement("anchor-proxy")
ap.addEventListener("anchor-click", e => {
console.log(e.detail)
})```
### 例外
```html
const ap = document.createElement("anchor-proxy")
ap.proxyFilters = [
(href, target) => !target.hasAttribute("data-proxy-disabled"),
]```