Skip to content

Commit

Permalink
Add description and update value diff check for input range
Browse files Browse the repository at this point in the history
  • Loading branch information
Illu committed May 30, 2018
1 parent 3203e0e commit 1684cfc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/react-dom/src/client/ReactDOMFiberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export function postMountWrapper(element: Element, props: Object) {

if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
const initialValue = '' + node._wrapperState.initialValue;

// With range inputs node.value may be a default value calculated from the
// min/max attributes. This ensures that node.value is set with the correct
// value coming from props.
const currentValue = props.type === 'range' ? '' : node.value;

// Do not assign value if it is already set. This prevents user text input
Expand All @@ -220,6 +224,8 @@ export function postMountWrapper(element: Element, props: Object) {
// prematurely marking required inputs as invalid
if (initialValue !== currentValue) {
node.value = initialValue;
} else if (props.type === 'range') {
node.value = initialValue;
}
}

Expand Down

0 comments on commit 1684cfc

Please sign in to comment.