open-index/open-npm huggingface dataset:
npm package: @holy-two/anchor-proxy
Description: 透过WebComponent对所有的a标签进行代理事件及拦截
Author: mowtwo
Latest version: 0.0.2

# @holy-two/anchor-proxy

透過 WebComponent 封裝的一個對所有的 `a` 標簽進行代理事件及攔截的功能

## 安裝

```bash
pnpm i @holy-two/anchor-proxy
```

## 基本

```html
<script type="module">
  import "@holy-two/anchor-proxy"
</script>

<anchor-proxy>
  <a href="/">主頁</a>
</anchor-proxy>

<script type="module">
  const ap = document.createElement("anchor-proxy")

  ap.addEventListener("anchor-click", e => {
    console.log(e.detail)
  })
</script>
```

### 例外

```html
<anchor-proxy>
  <a href="/">主頁</a>
  <a href="/admin" data-proxy-disabled>後臺</a>
</anchor-proxy>

<script type="module">
  const ap = document.createElement("anchor-proxy")

  ap.proxyFilters = [
    (href, target) => !target.hasAttribute("data-proxy-disabled"),
  ]
</script>
```