Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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 標簽進行代理事件及攔截

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"),
]

```