834
// listeners still fire for the invalid event.
835
listenToNonDelegatedEvent('invalid', domElement);
836
837
+ let name = null;
838
let type = null;
839
let value = null;
840
let defaultValue = null;
849
continue;
850
}
851
switch (propKey) {
852
+ case 'name': {
853
+ name = propValue;
854
+ break;
855
+ }
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;
858
break;
859
}
860
case 'checked': {
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';
862
break;
863
}
864
case 'defaultChecked': {
890
}
891
// TODO: Make sure we check if this is still unmounted or do any clean
892
// up necessary since we never stop tracking anymore.
907
- track((domElement: any));
893
validateInputProps(domElement, props);
894
initInput(
895
domElement,
898
checked,
899
defaultChecked,
900
type,
901
+ name,
902
false,
903
);
904
+ track((domElement: any));
905
return;
906
}
907
case 'select': {
997
}
998
// TODO: Make sure we check if this is still unmounted or do any clean
999
// up necessary since we never stop tracking anymore.
1013
- track((domElement: any));
1000
validateTextareaProps(domElement, props);
1001
initTextarea(domElement, value, defaultValue, children);
1002
+ track((domElement: any));
1003
return;
1004
}
1005
case 'option': {
1292
if (lastProps.hasOwnProperty(propKey) && lastProp != null) {
1293
switch (propKey) {
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
- }
1295
break;
1296
}
1297
case 'value': {
1320
switch (propKey) {
1321
case 'type': {
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
- }
1323
break;
1324
}
1325
case 'name': {
1328
}
1329
case 'checked': {
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
- }
1331
break;
1332
}
1333
case 'defaultChecked': {
1407
}
1408
}
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
-
1410
// Update the wrapper around inputs *after* updating props. This has to
1411
// happen after updating the rest of props. Otherwise HTML5 input validations
1412
// raise warnings and prevent the new value from being assigned.
1418
checked,
1419
defaultChecked,
1420
type,
1421
+ name,
1422
);
1423
return;
1424
}
1760
const propValue = updatePayload[i + 1];
1761
switch (propKey) {
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
- }
1763
break;
1764
}
1765
case 'name': {
1766
break;
1767
}
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';
1769
break;
1770
}
1771
case 'defaultChecked': {
1833
}
1834
}
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
-
1836
// Update the wrapper around inputs *after* updating props. This has to
1837
// happen after updating the rest of props. Otherwise HTML5 input validations
1838
// raise warnings and prevent the new value from being assigned.
1844
checked,
1845
defaultChecked,
1846
type,
1847
+ name,
1848
);
1849
return;
1850
}
2871
listenToNonDelegatedEvent('invalid', domElement);
2872
// TODO: Make sure we check if this is still unmounted or do any clean
2873
// up necessary since we never stop tracking anymore.
2973
- track((domElement: any));
2874
validateInputProps(domElement, props);
2875
// For input and textarea we current always set the value property at
2876
// post mount to force it to diverge from attributes. However, for
2884
props.checked,
2885
props.defaultChecked,
2886
props.type,
2887
+ props.name,
2888
true,
2889
);
2890
+ track((domElement: any));
2891
break;
2892
case 'option':
2893
validateOptionProps(domElement, props);
2910
listenToNonDelegatedEvent('invalid', domElement);
2911
// TODO: Make sure we check if this is still unmounted or do any clean
2912
// up necessary since we never stop tracking anymore.
3011
- track((domElement: any));
2913
validateTextareaProps(domElement, props);
2914
initTextarea(domElement, props.value, props.defaultValue, props.children);
2915
+ track((domElement: any));
2916
break;
2917
}
2918