facebook/react — pull request #2255 by syranide (2014-09-26 22:04:57+00:00)
Title: RFC: React-enhanced input/textarea/select should be addons

# What

This RFC-PR removes all React-specific enhancements from `ReactDOMInput`, `ReactDOMTextarea` and `ReactDOMSelect`. The controlled (and still optionally uncontrolled) implementations are now found in `React.addons.*` instead and are fully backwards-compatible. The implementations provided by React core are now bare-bones, focusing only on exposing the DOM in a predictable way, much like the rest of ReactDOM.

# Why was it flawed

`ReactDOMInput`, `ReactDOMTextarea` and `ReactDOMSelect` are very complex implementations and they're still far from perfect (and quite frequently patched). Worse, the implementations are really rather hacky. A generic neat and robust implementation simply doesn't seem possible. `` has to refresh `option.selected` for all options every render, the logic for `` is down-right horrendous and there are a number of edge-cases that do not behave as you would expect.

Trying to make ``, `` and `<select>` controlled for the generic use-case is flawed and as such doesn't belong in React core.

# Why is this better

`ReactDOM*` is mostly wrapped by users and packaged as their own `MyTextfield`, `MyButton`, etc components and React makes it fantastically simple. So there's no reason why they should be forced to use and bundle sub-optimal implementations even when they have significantly simpler requirements.

Implementing the React-enhanced controlled versions of `<input>`, `<textarea>` and `<select>` as addons/components is trivial. It allows the core implementations to stay lean and focus only on exposing the DOM consistently (and to patch `ReactDOM*` independently of React's release schedule). It allows the community to tailor the amount of logic to their own needs and to ignore edge-cases that simply aren't relevant, if they don't care, just use `React.addons.*`. Providing "pure" implementations of the controls would be trivial too for even more benefit.

There's no reason why this should be in React core. This PR as-is shaves ~4.3kb/1.2kb (~3-4%) of React core and can significantly reduce performance overhead for edge-cases.

# How

`ReactDOM*` now only accept initial values. `<input initialValue={...} initialChecked={...} />`, `<textarea initialValue={...} />` and `<select initialValue={...} />` (`initialSelected`?), feel free to object to `initial` vs `default`. `React.addons.*` are backwards-compatible implementations that extends the `ReactDOM*` exposed by React core.

Codemod:ing existing codebases should be trivial.

PS. This PR is not thoroughly coded/tested (yet) and includes some unrelated fixes, but the idea is sound and the implementation does work.

cc @zpao @petehunt @sebmarkbage @jordwalke @spicyj @chenglou