react / react/react

Stop syncing value attribute for controlled inputs

Aperta
#11,896 22 commenti 32 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Component: DOM Type: Breaking Change Type: Discussion
Lingua principale
JavaScript
Stelle
251k
Fork
51.4k
Merge medio
2g 4h
PR unite (30g)
53

Descrizione

Opening this as a follow up to some quick discussions in https://github.com/facebook/react/issues/11881. Syncing the value attribute has been a consistent source of bugs for us, and the benefits of doing so seem minimal. There's some previous discussion on the topic in https://github.com/facebook/react/pull/7359 and in other issues, I can't remember right now 😄

This would be a breaking change, so it would have to be done in a major release.

Reasons to keep syncing

  • It prevents form.reset() from putting controlled form inputs into a weird state
  • Some browser extensions (not sure which) read from the value attribute in some cases (not sure which)
  • It can be useful for querying inputs with a specific value using an attribute selector

Reasons to stop syncing

  • It will reduce the complexity of react-dom in a non-trivial way
  • In turn, it will likely reduce bundle size as well
  • We remove a whole class of bugs (fighting with browsers that want to be helpful about input values)
  • Syncing the input value to the attribute potentially exposes sensitive data to third party tools (1)

What do we think? Are these reasons good enough to keep syncing the value attribute? Are there other more critical reasons we should keep doing so?

cc @nhunzaker @jquense @gaearon

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Inizia esaminando la discussione nell’issue #11881 e la discussione precedente nella pull request #7359, quindi analizza come vengono gestiti gli input controllati in react-dom. Il lavoro non è ancora definito: per completarlo sarebbe necessario decidere un approccio per interrompere la sincronizzazione dell’attributo value e raggiungere un accordo sulle implicazioni del breaking change per una major release.

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

Valutazione

Stack tecnologico
javascript, react
Ambito
frontend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
20/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.