Skip to content

Commit

Permalink
Inline stringification of value in ReactDOMInput
Browse files Browse the repository at this point in the history
Avoids eagier stringification and makes usage more consistent.
  • Loading branch information
nhunzaker committed Nov 27, 2017
1 parent d8925a2 commit 5e194d1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/react-dom/src/client/ReactDOMFiberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export function updateWrapper(element: Element, props: Object) {
updateChecked(element, props);

var value = props.value;
var valueAsString = '' + props.value;
if (value != null) {
if (value === 0 && node.value === '') {
node.value = '0';
Expand All @@ -193,14 +192,14 @@ export function updateWrapper(element: Element, props: Object) {
) {
// Cast `value` to a string to ensure the value is set correctly. While
// browsers typically do this as necessary, jsdom doesn't.
node.value = valueAsString;
node.value = '' + value;
}
} else if (node.value !== valueAsString) {
} else if (node.value !== '' + value) {
// Cast `value` to a string to ensure the value is set correctly. While
// browsers typically do this as necessary, jsdom doesn't.
node.value = valueAsString;
node.value = '' + value
}
synchronizeDefaultValue(node, props.type, valueAsString);
synchronizeDefaultValue(node, props.type, '' + value);
} else {
if (props.value == null && props.defaultValue != null) {
synchronizeDefaultValue(node, props.type, '' + props.defaultValue);
Expand Down

0 comments on commit 5e194d1

Please sign in to comment.