Skip to content

Commit f5e5324

Browse files
committed
Re-eliminate the postmount wrapper with a special defaultValue mutation method
1 parent 89eb579 commit f5e5324

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

src/renderers/dom/client/wrappers/ReactDOMInput.js

-11
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,6 @@ var ReactDOMInput = {
178178
}
179179
},
180180

181-
postMountWrapper: function(inst) {
182-
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
183-
var props = inst._currentElement.props;
184-
185-
// Values derived from markup, like setting innerHTML or working
186-
// from server-rendered markup, will not have value assigned as a
187-
// property. It needs to be directly assigned to detatch it from
188-
// default value.
189-
node.value = node.value;
190-
},
191-
192181
// Ensure that there is no disconnect between an input's property
193182
// value and component state. This should run during `onChange`.
194183
enforceControlledInputValue: function(inst) {

src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,6 @@ describe('ReactDOMInput', function() {
771771
'set min',
772772
'set max',
773773
'set value',
774-
'set value' // second time is post mount
775774
]);
776775
});
777776

src/renderers/dom/shared/HTMLDOMPropertyConfig.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var HTMLDOMPropertyConfig = {
4141
'max',
4242
'value',
4343
'checked',
44-
'defaultChecked',
4544
],
4645
},
4746

@@ -247,6 +246,19 @@ var HTMLDOMPropertyConfig = {
247246
}
248247
},
249248

249+
defaultValue: function(node, next) {
250+
// If a value is present, intentially re-assign it to detatch it
251+
// from defaultValue. Values derived from server-rendered markup
252+
// will not had a prior changes to assign value as a property.
253+
//
254+
// Make an exception for multi-selects
255+
if (!node.multiple && node.value !== '') {
256+
node.value = node.value;
257+
}
258+
259+
node.defaultValue = next;
260+
},
261+
250262
// Chrome ~50 does not properly detatch defaultChecked, this mutation method
251263
// is a work around to mitigate a bug where setting defaultChecked changes
252264
// the value of checked, even after detachment:

src/renderers/dom/shared/ReactDOMComponent.js

-9
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,6 @@ function putListener() {
239239
);
240240
}
241241

242-
function inputPostMount() {
243-
var inst = this;
244-
ReactDOMInput.postMountWrapper(inst);
245-
}
246-
247242
function textareaPostMount() {
248243
var inst = this;
249244
ReactDOMTextarea.postMountWrapper(inst);
@@ -659,10 +654,6 @@ ReactDOMComponent.Mixin = {
659654

660655
switch (this._tag) {
661656
case 'input':
662-
transaction.getReactMountReady().enqueue(
663-
inputPostMount,
664-
this
665-
);
666657
if (props.autoFocus) {
667658
transaction.getReactMountReady().enqueue(
668659
AutoFocusUtils.focusDOMComponent,

0 commit comments

Comments
 (0)