Skip to content

Commit

Permalink
Re-eliminate the postmount wrapper with a special defaultValue mutati…
Browse files Browse the repository at this point in the history
…on method
  • Loading branch information
nhunzaker committed Aug 30, 2016
1 parent 094bc45 commit ae22ecf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
11 changes: 0 additions & 11 deletions src/renderers/dom/client/wrappers/ReactDOMInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,6 @@ var ReactDOMInput = {
}
},

postMountWrapper: function(inst) {
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
var props = inst._currentElement.props;

// Values derived from markup, like setting innerHTML or working
// from server-rendered markup, will not have value assigned as a
// property. It needs to be directly assigned to detatch it from
// default value.
node.value = node.value;
},

// Ensure that there is no disconnect between an input's property
// value and component state. This should run during `onChange`.
enforceControlledInputValue: function(inst) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,6 @@ describe('ReactDOMInput', function() {
'set min',
'set max',
'set value',
'set value' // second time is post mount
]);
});

Expand Down
14 changes: 13 additions & 1 deletion src/renderers/dom/shared/HTMLDOMPropertyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var HTMLDOMPropertyConfig = {
'max',
'value',
'checked',
'defaultChecked',
],
},

Expand Down Expand Up @@ -246,6 +245,19 @@ var HTMLDOMPropertyConfig = {
}
},

defaultValue: function(node, next) {
// If a value is present, intentially re-assign it to detatch it
// from defaultValue. Values derived from server-rendered markup
// will not had a prior changes to assign value as a property.
//
// Make an exception for multi-selects
if (!node.multiple && node.value !== '') {
node.value = node.value;
}

node.defaultValue = next;
},

// Chrome ~50 does not properly detatch defaultChecked, this mutation method
// is a work around to mitigate a bug where setting defaultChecked changes
// the value of checked, even after detachment:
Expand Down
9 changes: 0 additions & 9 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,6 @@ function putListener() {
);
}

function inputPostMount() {
var inst = this;
ReactDOMInput.postMountWrapper(inst);
}

function textareaPostMount() {
var inst = this;
ReactDOMTextarea.postMountWrapper(inst);
Expand Down Expand Up @@ -660,10 +655,6 @@ ReactDOMComponent.Mixin = {

switch (this._tag) {
case 'input':
transaction.getReactMountReady().enqueue(
inputPostMount,
this
);
if (props.autoFocus) {
transaction.getReactMountReady().enqueue(
AutoFocusUtils.focusDOMComponent,
Expand Down

0 comments on commit ae22ecf

Please sign in to comment.