Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Allow arbitrary data-* attributes on DOM elements in JSX

Aperta
#152 0 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react
Ambito
frontend

Direzione di ricerca

Inizia esaminando JsxDOM.domProps e la logica di convalida degli attributi JSX, che la proposta identifica come le aree rilevanti. Verifica il comportamento previsto con elementi DOM in minuscolo usando valori data-* statici e variabili; il risultato è raggiunto quando attributi data-* arbitrari vengono compilati senza estendere JsxDOM.domProps o usare un modulo JSX personalizzato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
ReScript
Stelle
517
Fork
45
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rescript-lang/rescript-react

Tutte le issue di rescript-lang/rescript-react

Issue simili

Altre issue su Web Dev

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.