@@ -834,6 +834,7 @@ export function setInitialProperties(
834
834
// listeners still fire for the invalid event.
835
835
listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
836
836
837
+ let name = null ;
837
838
let type = null ;
838
839
let value = null ;
839
840
let defaultValue = null ;
@@ -848,31 +849,16 @@ export function setInitialProperties(
848
849
continue ;
849
850
}
850
851
switch ( propKey ) {
852
+ case 'name' : {
853
+ name = propValue ;
854
+ break ;
855
+ }
851
856
case 'type' : {
852
- // Fast path since 'type' is very common on inputs
853
- if (
854
- propValue != null &&
855
- typeof propValue !== 'function' &&
856
- typeof propValue !== 'symbol' &&
857
- typeof propValue !== 'boolean'
858
- ) {
859
- type = propValue ;
860
- if ( __DEV__ ) {
861
- checkAttributeStringCoercion ( propValue , propKey ) ;
862
- }
863
- domElement . setAttribute ( propKey , propValue ) ;
864
- }
857
+ type = propValue ;
865
858
break ;
866
859
}
867
860
case 'checked' : {
868
861
checked = propValue ;
869
- const checkedValue =
870
- propValue != null ? propValue : props . defaultChecked ;
871
- const inputElement : HTMLInputElement = ( domElement : any ) ;
872
- inputElement . checked =
873
- ! ! checkedValue &&
874
- typeof checkedValue !== 'function' &&
875
- checkedValue !== 'symbol' ;
876
862
break ;
877
863
}
878
864
case 'defaultChecked' : {
@@ -904,7 +890,6 @@ export function setInitialProperties(
904
890
}
905
891
// TODO: Make sure we check if this is still unmounted or do any clean
906
892
// up necessary since we never stop tracking anymore.
907
- track ( ( domElement : any ) ) ;
908
893
validateInputProps ( domElement , props ) ;
909
894
initInput (
910
895
domElement ,
@@ -913,8 +898,10 @@ export function setInitialProperties(
913
898
checked ,
914
899
defaultChecked ,
915
900
type ,
901
+ name ,
916
902
false ,
917
903
) ;
904
+ track ( ( domElement : any ) ) ;
918
905
return ;
919
906
}
920
907
case 'select' : {
@@ -1010,9 +997,9 @@ export function setInitialProperties(
1010
997
}
1011
998
// TODO: Make sure we check if this is still unmounted or do any clean
1012
999
// up necessary since we never stop tracking anymore.
1013
- track ( ( domElement : any ) ) ;
1014
1000
validateTextareaProps ( domElement , props ) ;
1015
1001
initTextarea ( domElement , value , defaultValue , children ) ;
1002
+ track ( ( domElement : any ) ) ;
1016
1003
return ;
1017
1004
}
1018
1005
case 'option' : {
@@ -1305,14 +1292,6 @@ export function updateProperties(
1305
1292
if ( lastProps . hasOwnProperty ( propKey ) && lastProp != null ) {
1306
1293
switch ( propKey ) {
1307
1294
case 'checked' : {
1308
- if ( ! nextProps . hasOwnProperty ( propKey ) ) {
1309
- const checkedValue = nextProps . defaultChecked ;
1310
- const inputElement : HTMLInputElement = ( domElement : any ) ;
1311
- inputElement . checked =
1312
- ! ! checkedValue &&
1313
- typeof checkedValue !== 'function' &&
1314
- checkedValue !== 'symbol' ;
1315
- }
1316
1295
break ;
1317
1296
}
1318
1297
case 'value' : {
@@ -1341,22 +1320,6 @@ export function updateProperties(
1341
1320
switch ( propKey ) {
1342
1321
case 'type' : {
1343
1322
type = nextProp ;
1344
- // Fast path since 'type' is very common on inputs
1345
- if ( nextProp !== lastProp ) {
1346
- if (
1347
- nextProp != null &&
1348
- typeof nextProp !== 'function' &&
1349
- typeof nextProp !== 'symbol' &&
1350
- typeof nextProp !== 'boolean'
1351
- ) {
1352
- if ( __DEV__ ) {
1353
- checkAttributeStringCoercion ( nextProp , propKey ) ;
1354
- }
1355
- domElement . setAttribute ( propKey , nextProp ) ;
1356
- } else {
1357
- domElement . removeAttribute ( propKey ) ;
1358
- }
1359
- }
1360
1323
break ;
1361
1324
}
1362
1325
case 'name' : {
@@ -1365,15 +1328,6 @@ export function updateProperties(
1365
1328
}
1366
1329
case 'checked' : {
1367
1330
checked = nextProp ;
1368
- if ( nextProp !== lastProp ) {
1369
- const checkedValue =
1370
- nextProp != null ? nextProp : nextProps . defaultChecked ;
1371
- const inputElement : HTMLInputElement = ( domElement : any ) ;
1372
- inputElement . checked =
1373
- ! ! checkedValue &&
1374
- typeof checkedValue !== 'function' &&
1375
- checkedValue !== 'symbol' ;
1376
- }
1377
1331
break ;
1378
1332
}
1379
1333
case 'defaultChecked' : {
@@ -1453,23 +1407,6 @@ export function updateProperties(
1453
1407
}
1454
1408
}
1455
1409
1456
- // Update checked *before* name.
1457
- // In the middle of an update, it is possible to have multiple checked.
1458
- // When a checked radio tries to change name, browser makes another radio's checked false.
1459
- if (
1460
- name != null &&
1461
- typeof name !== 'function' &&
1462
- typeof name !== 'symbol' &&
1463
- typeof name !== 'boolean'
1464
- ) {
1465
- if ( __DEV__ ) {
1466
- checkAttributeStringCoercion ( name , 'name' ) ;
1467
- }
1468
- domElement . setAttribute ( 'name' , name ) ;
1469
- } else {
1470
- domElement . removeAttribute ( 'name' ) ;
1471
- }
1472
-
1473
1410
// Update the wrapper around inputs *after* updating props. This has to
1474
1411
// happen after updating the rest of props. Otherwise HTML5 input validations
1475
1412
// raise warnings and prevent the new value from being assigned.
@@ -1481,6 +1418,7 @@ export function updateProperties(
1481
1418
checked ,
1482
1419
defaultChecked ,
1483
1420
type ,
1421
+ name ,
1484
1422
) ;
1485
1423
return ;
1486
1424
}
@@ -1822,33 +1760,12 @@ export function updatePropertiesWithDiff(
1822
1760
const propValue = updatePayload [ i + 1 ] ;
1823
1761
switch ( propKey ) {
1824
1762
case 'type ': {
1825
- // Fast path since 'type' is very common on inputs
1826
- if (
1827
- propValue != null &&
1828
- typeof propValue !== 'function' &&
1829
- typeof propValue !== 'symbol' &&
1830
- typeof propValue !== 'boolean'
1831
- ) {
1832
- if ( __DEV__ ) {
1833
- checkAttributeStringCoercion ( propValue , propKey ) ;
1834
- }
1835
- domElement . setAttribute ( propKey , propValue ) ;
1836
- } else {
1837
- domElement . removeAttribute ( propKey ) ;
1838
- }
1839
1763
break ;
1840
1764
}
1841
1765
case 'name ': {
1842
1766
break ;
1843
1767
}
1844
1768
case 'checked ': {
1845
- const checkedValue =
1846
- propValue != null ? propValue : nextProps . defaultChecked ;
1847
- const inputElement : HTMLInputElement = ( domElement : any ) ;
1848
- inputElement . checked =
1849
- ! ! checkedValue &&
1850
- typeof checkedValue !== 'function' &&
1851
- checkedValue !== 'symbol' ;
1852
1769
break ;
1853
1770
}
1854
1771
case 'defaultChecked ': {
@@ -1916,23 +1833,6 @@ export function updatePropertiesWithDiff(
1916
1833
}
1917
1834
}
1918
1835
1919
- // Update checked *before* name.
1920
- // In the middle of an update, it is possible to have multiple checked.
1921
- // When a checked radio tries to change name, browser makes another radio's checked false.
1922
- if (
1923
- name != null &&
1924
- typeof name !== 'function' &&
1925
- typeof name !== 'symbol' &&
1926
- typeof name !== 'boolean'
1927
- ) {
1928
- if ( __DEV__ ) {
1929
- checkAttributeStringCoercion ( name , 'name' ) ;
1930
- }
1931
- domElement . setAttribute ( 'name' , name ) ;
1932
- } else {
1933
- domElement . removeAttribute ( 'name' ) ;
1934
- }
1935
-
1936
1836
// Update the wrapper around inputs *after* updating props. This has to
1937
1837
// happen after updating the rest of props. Otherwise HTML5 input validations
1938
1838
// raise warnings and prevent the new value from being assigned.
@@ -1944,6 +1844,7 @@ export function updatePropertiesWithDiff(
1944
1844
checked ,
1945
1845
defaultChecked ,
1946
1846
type ,
1847
+ name ,
1947
1848
) ;
1948
1849
return ;
1949
1850
}
@@ -2970,7 +2871,6 @@ export function diffHydratedProperties(
2970
2871
listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
2971
2872
// TODO: Make sure we check if this is still unmounted or do any clean
2972
2873
// up necessary since we never stop tracking anymore.
2973
- track ( ( domElement : any ) ) ;
2974
2874
validateInputProps ( domElement , props ) ;
2975
2875
// For input and textarea we current always set the value property at
2976
2876
// post mount to force it to diverge from attributes. However, for
@@ -2984,8 +2884,10 @@ export function diffHydratedProperties(
2984
2884
props . checked ,
2985
2885
props . defaultChecked ,
2986
2886
props . type ,
2887
+ props . name ,
2987
2888
true ,
2988
2889
) ;
2890
+ track ( ( domElement : any ) ) ;
2989
2891
break ;
2990
2892
case 'option' :
2991
2893
validateOptionProps ( domElement , props ) ;
@@ -3008,9 +2910,9 @@ export function diffHydratedProperties(
3008
2910
listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
3009
2911
// TODO: Make sure we check if this is still unmounted or do any clean
3010
2912
// up necessary since we never stop tracking anymore.
3011
- track ( ( domElement : any ) ) ;
3012
2913
validateTextareaProps ( domElement , props ) ;
3013
2914
initTextarea ( domElement , props . value , props . defaultValue , props . children ) ;
2915
+ track ( ( domElement : any ) ) ;
3014
2916
break ;
3015
2917
}
3016
2918
0 commit comments