Allow arbitrary data-* attributes on DOM elements in JSX
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react
- 領域
- frontend
調査の方向性
まず、提案で関連する領域として特定されている JsxDOM.domProps と JSX 属性検証ロジックを調べます。静的および変数の data-* 値を使用して小文字の DOM 要素で期待される動作を確認します。JsxDOM.domProps を拡張したり、カスタム JSX モジュールを使用したりせずに、任意の data-* 属性をコンパイルできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Problem
Currently data-* attributes cannot be used directly on HTML elements in ReScript JSX.
Example:
<input data-component="true" />
This produces the compiler error:
The field data-component does not belong to type JsxDOM.domProps
To use data-* attributes developers currently need to:
- extend
JsxDOM.domProps - implement a custom JSX module
- bypass JSX with
React.createElement
This introduces unnecessary complexity for a very common HTML pattern and reduces JSX ergonomics.
Context
data-* attributes are part of the HTML standard and are widely used across the React ecosystem for:
- CSS state selectors
- design-system variants
- testing hooks (
data-testid) - UI libraries such as Radix UI, Headless UI, and similar component systems
Example commonly used in modern component libraries:
<button data-state="open" data-variant="primary" />
CSS:
button[data-state="open"] {
background: green;
}
This pattern is heavily used in modern design systems and utility-CSS ecosystems because it allows component state to be expressed declaratively and consumed by CSS.
Proposal
Allow arbitrary attributes matching the pattern:
data-*
on lowercase DOM elements in JSX without requiring them to be explicitly declared in JsxDOM.domProps.
This could be implemented as a special case in JSX attribute validation.
Benefits
- better interoperability with the React ecosystem
- easier migration of existing React / TypeScript codebases
- simpler implementation of design systems
- avoids the need for custom JSX infrastructure for a standard HTML feature
Expected developer experience
Developers should be able to write JSX like this without additional configuration:
<button data-state="open" data-variant="primary" />
In real-world usage these attributes often contain values coming from ReScript variables, component props, or state:
@react.component
let make = (~variant: string, ~isOpen: bool, ~count: int) => {
<button
data-state={isOpen ? "open" : "closed"}
data-variant={variant}
data-count={count}
>
{React.string("Click")}
</button>
}
This pattern is widely used in React codebases and design systems, where data-* attributes act as a bridge between component state and CSS.
- 主要言語
- ReScript
- スター
- 517
- フォーク
- 45
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rescript-lang/rescript-react のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
rescript-lang/rescript-react#145 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
rescript-lang/rescript-react#147 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
rescript-lang/rescript-react#111 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
rescript-lang/rescript-react#105 ·
-
Scroll Restoration オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
rescript-lang/rescript-react#104 · リアクション 1 件 ·
rescript-lang/rescript-react の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
lobehub/lobe-icons#422 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
-
www.guideflow.com オープンN: AdGuard Browser Extension P4: Low T: Social Widget
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
AdguardTeam/AdguardFilters#242250 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100