Skip to content

Commit 6cd6ba7

Browse files
authored
Land enableNewBooleanProps everywhere (#28676)
Rolled out internally. Removing flag.
1 parent 425f72b commit 6cd6ba7

14 files changed

+74
-140
lines changed

packages/react-dom-bindings/src/client/ReactDOMComponent.js

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import {
7070
disableIEWorkarounds,
7171
enableTrustedTypesIntegration,
7272
enableFilterEmptyStringAttributesDOM,
73-
enableNewBooleanProps,
7473
} from 'shared/ReactFeatureFlags';
7574
import {
7675
mediaEventTypes,
@@ -668,24 +667,20 @@ function setProp(
668667
break;
669668
}
670669
// Boolean
671-
case 'inert':
672-
if (!enableNewBooleanProps) {
673-
setValueForAttribute(domElement, key, value);
674-
break;
675-
} else {
676-
if (__DEV__) {
677-
if (value === '' && !didWarnForNewBooleanPropsWithEmptyValue[key]) {
678-
didWarnForNewBooleanPropsWithEmptyValue[key] = true;
679-
console.error(
680-
'Received an empty string for a boolean attribute `%s`. ' +
681-
'This will treat the attribute as if it were false. ' +
682-
'Either pass `false` to silence this warning, or ' +
683-
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
684-
key,
685-
);
686-
}
670+
case 'inert': {
671+
if (__DEV__) {
672+
if (value === '' && !didWarnForNewBooleanPropsWithEmptyValue[key]) {
673+
didWarnForNewBooleanPropsWithEmptyValue[key] = true;
674+
console.error(
675+
'Received an empty string for a boolean attribute `%s`. ' +
676+
'This will treat the attribute as if it were false. ' +
677+
'Either pass `false` to silence this warning, or ' +
678+
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
679+
key,
680+
);
687681
}
688682
}
683+
}
689684
// fallthrough for new boolean props without the flag on
690685
case 'allowFullScreen':
691686
case 'async':
@@ -2764,32 +2759,30 @@ function diffHydratedGenericElement(
27642759
);
27652760
continue;
27662761
case 'inert':
2767-
if (enableNewBooleanProps) {
2768-
if (__DEV__) {
2769-
if (
2770-
value === '' &&
2771-
!didWarnForNewBooleanPropsWithEmptyValue[propKey]
2772-
) {
2773-
didWarnForNewBooleanPropsWithEmptyValue[propKey] = true;
2774-
console.error(
2775-
'Received an empty string for a boolean attribute `%s`. ' +
2776-
'This will treat the attribute as if it were false. ' +
2777-
'Either pass `false` to silence this warning, or ' +
2778-
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
2779-
propKey,
2780-
);
2781-
}
2762+
if (__DEV__) {
2763+
if (
2764+
value === '' &&
2765+
!didWarnForNewBooleanPropsWithEmptyValue[propKey]
2766+
) {
2767+
didWarnForNewBooleanPropsWithEmptyValue[propKey] = true;
2768+
console.error(
2769+
'Received an empty string for a boolean attribute `%s`. ' +
2770+
'This will treat the attribute as if it were false. ' +
2771+
'Either pass `false` to silence this warning, or ' +
2772+
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
2773+
propKey,
2774+
);
27822775
}
2783-
hydrateBooleanAttribute(
2784-
domElement,
2785-
propKey,
2786-
propKey,
2787-
value,
2788-
extraAttributes,
2789-
serverDifferences,
2790-
);
2791-
continue;
27922776
}
2777+
hydrateBooleanAttribute(
2778+
domElement,
2779+
propKey,
2780+
propKey,
2781+
value,
2782+
extraAttributes,
2783+
serverDifferences,
2784+
);
2785+
continue;
27932786
// fallthrough for new boolean props without the flag on
27942787
default: {
27952788
if (

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
enableBigIntSupport,
3232
enableFilterEmptyStringAttributesDOM,
3333
enableFizzExternalRuntime,
34-
enableNewBooleanProps,
3534
} from 'shared/ReactFeatureFlags';
3635

3736
import type {
@@ -1423,29 +1422,27 @@ function pushAttribute(
14231422
pushStringAttribute(target, 'xml:space', value);
14241423
return;
14251424
case 'inert': {
1426-
if (enableNewBooleanProps) {
1427-
if (__DEV__) {
1428-
if (value === '' && !didWarnForNewBooleanPropsWithEmptyValue[name]) {
1429-
didWarnForNewBooleanPropsWithEmptyValue[name] = true;
1430-
console.error(
1431-
'Received an empty string for a boolean attribute `%s`. ' +
1432-
'This will treat the attribute as if it were false. ' +
1433-
'Either pass `false` to silence this warning, or ' +
1434-
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
1435-
name,
1436-
);
1437-
}
1438-
}
1439-
// Boolean
1440-
if (value && typeof value !== 'function' && typeof value !== 'symbol') {
1441-
target.push(
1442-
attributeSeparator,
1443-
stringToChunk(name),
1444-
attributeEmptyString,
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,
14451434
);
14461435
}
1447-
return;
14481436
}
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;
14491446
}
14501447
// fallthrough for new boolean props without the flag on
14511448
default:

packages/react-dom-bindings/src/shared/ReactDOMUnknownPropertyHook.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {ATTRIBUTE_NAME_CHAR} from './isAttributeNameSafe';
99
import isCustomElement from './isCustomElement';
1010
import possibleStandardNames from './possibleStandardNames';
1111
import hasOwnProperty from 'shared/hasOwnProperty';
12-
import {enableNewBooleanProps} from 'shared/ReactFeatureFlags';
1312

1413
const warnedProperties = {};
1514
const EVENT_NAME_REGEX = /^on./;
@@ -228,18 +227,12 @@ function validateProperty(tagName, name, value, eventRegistry) {
228227
case 'seamless':
229228
case 'itemScope':
230229
case 'capture':
231-
case 'download': {
230+
case 'download':
231+
case 'inert': {
232232
// Boolean properties can accept boolean values
233233
return true;
234234
}
235235
// fallthrough
236-
case 'inert': {
237-
if (enableNewBooleanProps) {
238-
// Boolean properties can accept boolean values
239-
return true;
240-
}
241-
}
242-
// fallthrough for new boolean props without the flag on
243236
default: {
244237
const prefix = name.toLowerCase().slice(0, 5);
245238
if (prefix === 'data-' || prefix === 'aria-') {
@@ -311,15 +304,10 @@ function validateProperty(tagName, name, value, eventRegistry) {
311304
case 'reversed':
312305
case 'scoped':
313306
case 'seamless':
314-
case 'itemScope': {
315-
break;
316-
}
307+
case 'itemScope':
317308
case 'inert': {
318-
if (enableNewBooleanProps) {
319-
break;
320-
}
309+
break;
321310
}
322-
// fallthrough for new boolean props without the flag on
323311
default: {
324312
return true;
325313
}

packages/react-dom-bindings/src/shared/possibleStandardNames.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
import {enableNewBooleanProps} from 'shared/ReactFeatureFlags';
87

98
// When adding attributes to the HTML or SVG allowed attribute list, be sure to
109
// also add them to this module to ensure casing and incorrect name
@@ -83,6 +82,7 @@ const possibleStandardNames = {
8382
id: 'id',
8483
imagesizes: 'imageSizes',
8584
imagesrcset: 'imageSrcSet',
85+
inert: 'inert',
8686
innerhtml: 'innerHTML',
8787
inputmode: 'inputMode',
8888
integrity: 'integrity',
@@ -503,8 +503,4 @@ const possibleStandardNames = {
503503
zoomandpan: 'zoomAndPan',
504504
};
505505

506-
if (enableNewBooleanProps) {
507-
possibleStandardNames.inert = 'inert';
508-
}
509-
510506
export default possibleStandardNames;

packages/react-dom/src/__tests__/ReactDOMAttribute-test.js

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
describe('ReactDOM unknown attribute', () => {
1313
let React;
1414
let ReactDOMClient;
15-
let ReactFeatureFlags;
1615
let act;
1716

1817
beforeEach(() => {
1918
jest.resetModules();
2019
React = require('react');
2120
ReactDOMClient = require('react-dom/client');
22-
ReactFeatureFlags = require('shared/ReactFeatureFlags');
2321
act = require('internal-test-utils').act;
2422
});
2523

@@ -98,15 +96,9 @@ describe('ReactDOM unknown attribute', () => {
9896
await act(() => {
9997
root.render(<div inert={true} />);
10098
});
101-
}).toErrorDev(
102-
ReactFeatureFlags.enableNewBooleanProps
103-
? []
104-
: ['Warning: Received `true` for a non-boolean attribute `inert`.'],
105-
);
99+
}).toErrorDev([]);
106100

107-
expect(el.firstChild.getAttribute('inert')).toBe(
108-
ReactFeatureFlags.enableNewBooleanProps ? '' : null,
109-
);
101+
expect(el.firstChild.getAttribute('inert')).toBe(true ? '' : null);
110102
});
111103

112104
it('warns once for empty strings in new boolean props', async () => {
@@ -117,20 +109,14 @@ describe('ReactDOM unknown attribute', () => {
117109
await act(() => {
118110
root.render(<div inert="" />);
119111
});
120-
}).toErrorDev(
121-
ReactFeatureFlags.enableNewBooleanProps
122-
? [
123-
'Warning: Received an empty string for a boolean attribute `inert`. ' +
124-
'This will treat the attribute as if it were false. ' +
125-
'Either pass `false` to silence this warning, or ' +
126-
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
127-
]
128-
: [],
129-
);
130-
131-
expect(el.firstChild.getAttribute('inert')).toBe(
132-
ReactFeatureFlags.enableNewBooleanProps ? null : '',
133-
);
112+
}).toErrorDev([
113+
'Warning: Received an empty string for a boolean attribute `inert`. ' +
114+
'This will treat the attribute as if it were false. ' +
115+
'Either pass `false` to silence this warning, or ' +
116+
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
117+
]);
118+
119+
expect(el.firstChild.getAttribute('inert')).toBe(true ? null : '');
134120

135121
// The warning is only printed once.
136122
await act(() => {

packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -742,36 +742,24 @@ describe('ReactDOMServerIntegration', () => {
742742
});
743743

744744
itRenders('new boolean `true` attributes', async render => {
745-
const element = await render(
746-
<div inert={true} />,
747-
ReactFeatureFlags.enableNewBooleanProps ? 0 : 1,
748-
);
745+
const element = await render(<div inert={true} />, 0);
749746

750-
expect(element.getAttribute('inert')).toBe(
751-
ReactFeatureFlags.enableNewBooleanProps ? '' : null,
752-
);
747+
expect(element.getAttribute('inert')).toBe('');
753748
});
754749

755750
itRenders('new boolean `""` attributes', async render => {
756751
const element = await render(
757752
<div inert="" />,
758-
ReactFeatureFlags.enableNewBooleanProps
759-
? // Warns since this used to render `inert=""` like `inert={true}`
760-
// but now renders it like `inert={false}`.
761-
1
762-
: 0,
753+
// Warns since this used to render `inert=""` like `inert={true}`
754+
// but now renders it like `inert={false}`.
755+
1,
763756
);
764757

765-
expect(element.getAttribute('inert')).toBe(
766-
ReactFeatureFlags.enableNewBooleanProps ? null : '',
767-
);
758+
expect(element.getAttribute('inert')).toBe(null);
768759
});
769760

770761
itRenders('new boolean `false` attributes', async render => {
771-
const element = await render(
772-
<div inert={false} />,
773-
ReactFeatureFlags.enableNewBooleanProps ? 0 : 1,
774-
);
762+
const element = await render(<div inert={false} />, 0);
775763

776764
expect(element.getAttribute('inert')).toBe(null);
777765
});

packages/shared/ReactFeatureFlags.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,6 @@ export const disableLegacyMode = __NEXT_MAJOR__;
183183

184184
export const disableDOMTestUtils = __NEXT_MAJOR__;
185185

186-
// HTML boolean attributes need a special PropertyInfoRecord.
187-
// Between support of these attributes in browsers and React supporting them as
188-
// boolean props library users can use them as `<div someBooleanAttribute="" />`.
189-
// However, once React considers them as boolean props an empty string will
190-
// result in false property i.e. break existing usage.
191-
export const enableNewBooleanProps = __NEXT_MAJOR__;
192-
193186
// Make <Context> equivalent to <Context.Provider> instead of <Context.Consumer>
194187
export const enableRenderableContext = __NEXT_MAJOR__;
195188

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export const enableLazyContextPropagation = false;
7878
export const enableLegacyHidden = false;
7979
export const forceConcurrentByDefaultForTesting = false;
8080
export const allowConcurrentByDefault = false;
81-
export const enableNewBooleanProps = true;
8281

8382
export const enableTransitionTracing = false;
8483

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export const enableLazyContextPropagation = false;
9999
export const enableLegacyHidden = false;
100100
export const forceConcurrentByDefaultForTesting = false;
101101
export const allowConcurrentByDefault = false;
102-
export const enableNewBooleanProps = true;
103102
export const enableTransitionTracing = false;
104103
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
105104
export const passChildrenWhenCloningPersistedNodes = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ export const enableBigIntSupport = __NEXT_MAJOR__;
9292
export const disableLegacyMode = __NEXT_MAJOR__;
9393
export const disableLegacyContext = __NEXT_MAJOR__;
9494
export const disableDOMTestUtils = __NEXT_MAJOR__;
95-
export const enableNewBooleanProps = __NEXT_MAJOR__;
9695
export const enableRenderableContext = __NEXT_MAJOR__;
9796
export const enableReactTestRendererWarning = __NEXT_MAJOR__;
9897

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const enableLegacyHidden = false;
5959
export const forceConcurrentByDefaultForTesting = false;
6060
export const enableUnifiedSyncLane = true;
6161
export const allowConcurrentByDefault = true;
62-
export const enableNewBooleanProps = true;
6362

6463
export const consoleManagedByDevToolsDuringStrictMode = false;
6564

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const enableLegacyHidden = false;
5959
export const forceConcurrentByDefaultForTesting = false;
6060
export const enableUnifiedSyncLane = true;
6161
export const allowConcurrentByDefault = true;
62-
export const enableNewBooleanProps = false;
6362

6463
export const consoleManagedByDevToolsDuringStrictMode = false;
6564

packages/shared/forks/ReactFeatureFlags.www-dynamic.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const enableUseDeferredValueInitialArg = __VARIANT__;
3030
export const enableRenderableContext = __VARIANT__;
3131
export const useModernStrictMode = __VARIANT__;
3232
export const enableRefAsProp = __VARIANT__;
33-
export const enableNewBooleanProps = __VARIANT__;
3433
export const enableRetryLaneExpiration = __VARIANT__;
3534
export const favorSafetyOverHydrationPerf = __VARIANT__;
3635
export const retryLaneExpirationMs = 5000;

0 commit comments

Comments
 (0)