@samitouri / QOS-React / commits / 5c737b9550

Don't detach value from defaultValue for submit/reset inputs (#7197)

Paul O’Shannessy committed Jul 5, 2016 at 16:39 UTC 5c737b9550906879bfaa5f976a6251f858cf2aa8
1 file changed +11 -1
src/renderers/dom/client/wrappers/ReactDOMInput.js
+11 -1
@@ -216,10 +216,20 @@ var ReactDOMInput = {
216 },
217
218 postMountWrapper: function(inst) {
219 + var props = inst._currentElement.props;
220 +
221 // This is in postMount because we need access to the DOM node, which is not
222 // available until after the component has mounted.
223 var node = ReactDOMComponentTree.getNodeFromInstance(inst);
222 - node.value = node.value; // Detach value from defaultValue
224 +
225 + // Detach value from defaultValue. We won't do anything if we're working on
226 + // submit or reset inputs as those values & defaultValues are linked. They
227 + // are not resetable nodes so this operation doesn't matter and actually
228 + // removes browser-default values (eg "Submit Query") when no value is
229 + // provided.
230 + if (props.type !== 'submit' && props.type !== 'reset') {
231 + node.value = node.value;
232 + }
233
234 // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
235 // this is needed to work around a chrome bug where setting defaultChecked