Find a way to allow "@" in attribute?
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 38/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript
- 領域
- frontend
研究方向
從提供的 htm/preact 重現開始,檢查屬性如何傳遞到 setAttribute,尤其是 @click 的情況。將其行為與 x-on:click workaround 以及連結的 Alpine issues 進行比較;當 Alpine 的 @ 語法無需使用者重寫即可正常運作,並以該重現作為檢查依據時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Both Vue and Alpine have this weird syntax where events get preceded by @. I'm using htm in a library for templating. Preact is more of an implementation detail, and not really exposed to users. I'm seeing someone who uses alpine on the rest of the page and wants an event handler that's handled by alpine in that template. Unfortunately the shorthand syntax doesn't seem to work due to setAttribute.
A reproduction is:
import { render } from "preact";
import { html } from "htm/preact";
// does work
render(
html`
<div x-data="{ open: false }">
<button @click="open = !open">Expand</button>
<span x-show="open">
Content...
</span>
</div>
`,
document.body
);
(workaround is replacing @ to x-on:, but our user wasn't aware of this)
sandbox: https://codesandbox.io/s/festive-wildflower-qeugtn?file=/src/index.js
other relevant issues:
https://github.com/alpinejs/alpine/issues/1235
https://github.com/alpinejs/alpine/issues/396
https://github.com/algolia/instantsearch/issues/5435
I'm guessing no workaround will be possible as it's actually setAttribute throwing, but I wonder if you know something that would avoid users changing their expectations.
- 主要語言
- JavaScript
- 星號
- 9k
- 分支
- 181
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
developit/htm 的其他 Issue
-
Sarthak 未關閉
難度 5/5 一週以上 新手友好度 1/100
-
Tugas 未關閉
難度 5/5 一週以上 新手友好度 10/100
-
Tugas 未關閉
難度 5/5 一週以上 新手友好度 1/100
-
難度 5/5 一週以上 新手友好度 20/100
-
難度 2/5 1-3 小時 新手友好度 35/100
相似的 Issue
-
bug confirmed issue
難度 2/5 1-3 小時 新手友好度 75/100
open-webui/open-webui#30750 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
-
Mend: dependency security vulnerability untriaged
難度 2/5 1-3 小時 新手友好度 70/100