Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Find a way to allow "@" in attribute?

オープン
#235 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
frontend

調査の方向性

提供された htm/preact の再現ケースから始め、属性がどのように setAttribute に渡るか、特に @click のケースを調べます。x-on:click の回避策およびリンクされている Alpine の issue と動作を比較します。再現ケースを確認手段として、ユーザーが書き換えなくても 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 はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

developit/htm のほかの issue

developit/htm の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。