Cleanup enableNewBooleanProps (#28712)
Sebastian Silbermann committed
Apr 2, 2024 at 17:09 UTC
28fc980ef2c563e3086ae5b0b2e6293de48ae0d4
2 files changed
+16
-26
packages/react-dom-bindings/src/client/ReactDOMComponent.js
+1
-2
@@ -681,7 +681,7 @@ function setProp(
681
}
682
}
683
}
684
- // fallthrough for new boolean props without the flag on
684
+ // Fallthrough for boolean props that don't have a warning for empty strings.
685
case 'allowFullScreen':
686
case 'async':
687
case 'autoPlay':
@@ -2783,7 +2783,6 @@ function diffHydratedGenericElement(
2783
serverDifferences,
2784
);
2785
continue;
2786
- // fallthrough for new boolean props without the flag on
2786
default: {
2787
if (
2788
// shouldIgnoreAttribute
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+15
-24
@@ -1301,6 +1301,21 @@ function pushAttribute(
1301
}
1302
return;
1303
}
1304
+ case 'inert': {
1305
+ if (__DEV__) {
1306
+ if (value === '' && !didWarnForNewBooleanPropsWithEmptyValue[name]) {
1307
+ didWarnForNewBooleanPropsWithEmptyValue[name] = true;
1308
+ console.error(
1309
+ 'Received an empty string for a boolean attribute `%s`. ' +
1310
+ 'This will treat the attribute as if it were false. ' +
1311
+ 'Either pass `false` to silence this warning, or ' +
1312
+ 'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
1313
+ name,
1314
+ );
1315
+ }
1316
+ }
1317
+ }
1318
+ // Fallthrough for boolean props that don't have a warning for empty strings.
1319
case 'allowFullScreen':
1320
case 'async':
1321
case 'autoPlay':
@@ -1421,30 +1436,6 @@ function pushAttribute(
1436
case 'xmlSpace':
1437
pushStringAttribute(target, 'xml:space', value);
1438
return;
1424
- case 'inert': {
1425
- if (__DEV__) {
1426
- if (value === '' && !didWarnForNewBooleanPropsWithEmptyValue[name]) {
1427
- didWarnForNewBooleanPropsWithEmptyValue[name] = true;
1428
- console.error(
1429
- 'Received an empty string for a boolean attribute `%s`. ' +
1430
- 'This will treat the attribute as if it were false. ' +
1431
- 'Either pass `false` to silence this warning, or ' +
1432
- 'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
1433
- name,
1434
- );
1435
- }
1436
- }
1437
- // Boolean
1438
- if (value && typeof value !== 'function' && typeof value !== 'symbol') {
1439
- target.push(
1440
- attributeSeparator,
1441
- stringToChunk(name),
1442
- attributeEmptyString,
1443
- );
1444
- }
1445
- return;
1446
- }
1447
- // fallthrough for new boolean props without the flag on
1439
default:
1440
if (
1441
// shouldIgnoreAttribute