@@ -252,17 +252,17 @@ export function postMountWrapper(
252
252
return ;
253
253
}
254
254
255
- const initialValue = node . _wrapperState . initialValue ;
255
+ const initialValue = toString ( node . _wrapperState . initialValue ) ;
256
256
257
257
// Do not assign value if it is already set. This prevents user text input
258
258
// from being lost during SSR hydration.
259
259
if ( ! isHydrating ) {
260
260
if ( disableInputAttributeSyncing ) {
261
+ const value = getToStringValue ( props . value ) ;
262
+
261
263
// When not syncing the value attribute, the value property points
262
264
// directly to the React prop. Only assign it if it exists.
263
- if ( props . hasOwnProperty ( 'value' ) ) {
264
- const value = getToStringValue ( props . value ) ;
265
-
265
+ if ( value != null ) {
266
266
// Always assign on buttons so that it is possible to assign an
267
267
// empty string to clear button text.
268
268
//
@@ -283,22 +283,23 @@ export function postMountWrapper(
283
283
// 2. The defaultValue React property when present
284
284
// 3. An empty string
285
285
if ( initialValue !== node . value ) {
286
- node . value = toString ( initialValue ) ;
286
+ node . value = initialValue ;
287
287
}
288
288
}
289
289
}
290
290
291
291
if ( disableInputAttributeSyncing ) {
292
292
// When not syncing the value attribute, assign the value attribute
293
293
// directly from the defaultValue React property (when present)
294
- if ( props . hasOwnProperty ( 'defaultValue' ) ) {
295
- node . defaultValue = toString ( getToStringValue ( props . defaultValue ) ) ;
294
+ const defaultValue = getToStringValue ( props . defaultValue ) ;
295
+ if ( defaultValue != null ) {
296
+ node . defaultValue = toString ( defaultValue ) ;
296
297
}
297
298
} else {
298
299
// Otherwise, the value attribute is synchronized to the property,
299
300
// so we assign defaultValue to the same thing as the value property
300
301
// assignment step above.
301
- node . defaultValue = toString ( initialValue ) ;
302
+ node . defaultValue = initialValue ;
302
303
}
303
304
}
304
305
0 commit comments