@@ -35,8 +35,21 @@ let didWarnControlledToUncontrolled = false;
3535let didWarnUncontrolledToControlled = false ;
3636
3737function isControlled ( props ) {
38- const usesChecked = props . type === 'checkbox' || props . type === 'radio' ;
39- return usesChecked ? props . checked != null : props . value != null ;
38+ if ( props . type === 'checkbox' || props . type === 'radio' ) {
39+ return props . checked != null ;
40+ } else if ( props . type === 'submit' || props . type === 'reset' ) {
41+ return props . hasOwnProperty ( 'value' ) ;
42+ } else {
43+ return props . value != null ;
44+ }
45+ }
46+
47+ function isSubmitOrResetButtonWithEmptyValue ( props ) {
48+ if ( props . type !== 'submit' || props . type !== 'reset' ) {
49+ return false ;
50+ }
51+
52+ return props . value === undefined || props . value === null ;
4053}
4154
4255/**
@@ -194,7 +207,9 @@ export function updateWrapper(element: Element, props: Object) {
194207 }
195208 }
196209
197- if ( props . hasOwnProperty ( 'value' ) ) {
210+ if ( isSubmitOrResetButtonWithEmptyValue ( props ) ) {
211+ node . removeAttribute ( 'value' ) ;
212+ } else if ( props . hasOwnProperty ( 'value' ) ) {
198213 setDefaultValue ( node , props . type , value ) ;
199214 } else if ( props . hasOwnProperty ( 'defaultValue' ) ) {
200215 setDefaultValue ( node , props . type , getSafeValue ( props . defaultValue ) ) ;
@@ -208,7 +223,13 @@ export function updateWrapper(element: Element, props: Object) {
208223export function postMountWrapper ( element : Element , props : Object ) {
209224 const node = ( ( element : any ) : InputWithWrapperState ) ;
210225
211- if ( props . hasOwnProperty ( 'value' ) || props . hasOwnProperty ( 'defaultValue' ) ) {
226+ if (
227+ ! isSubmitOrResetButtonWithEmptyValue ( props ) && (
228+ props . hasOwnProperty ( 'value' ) ||
229+ props . hasOwnProperty ( 'defaultValue' )
230+ )
231+ ) {
232+
212233 // Do not assign value if it is already set. This prevents user text input
213234 // from being lost during SSR hydration.
214235 if ( node . value === '' ) {
0 commit comments