Skip to content

Commit

Permalink
Use the same value synchronization function on number blur
Browse files Browse the repository at this point in the history
I updated ReactDOMInput.synchronizeDefaultValue such that it assignes
the defaultValue property instead of the value attribute. I never
followed up on the ChangeEventPlugin's on blur behavior.
  • Loading branch information
nhunzaker committed Dec 1, 2017
1 parent 6c1fba5 commit bb41c4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMFiberInput.js
Expand Up @@ -307,7 +307,7 @@ function updateNamedCousins(rootNode, props) {
// when the user is inputting text
//
// https://github.com/facebook/react/issues/7253
function synchronizeDefaultValue(
export function synchronizeDefaultValue(
node: InputWithWrapperState,
type: ?string,
value: *,
Expand Down
6 changes: 2 additions & 4 deletions packages/react-dom/src/events/ChangeEventPlugin.js
Expand Up @@ -17,6 +17,7 @@ import getEventTarget from './getEventTarget';
import isEventSupported from './isEventSupported';
import {getNodeFromInstance} from '../client/ReactDOMComponentTree';
import * as inputValueTracking from '../client/inputValueTracking';
import {synchronizeDefaultValue} from '../client/ReactDOMFiberInput';

var eventTypes = {
change: {
Expand Down Expand Up @@ -235,10 +236,7 @@ function handleControlledInputBlur(inst, node) {
}

// If controlled, assign the value attribute to the current value on blur
let value = '' + node.value;
if (node.getAttribute('value') !== value) {
node.setAttribute('value', value);
}
synchronizeDefaultValue(node, 'number', node.value);
}

/**
Expand Down

0 comments on commit bb41c4a

Please sign in to comment.