Skip to content

Commit 0f967dc

Browse files
committed
Add support behind enableNewBooleanProps flag
1 parent a3c152f commit 0f967dc

10 files changed

+29
-4
lines changed

packages/react-dom/src/shared/DOMProperty.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import {
1111
enableFilterEmptyStringAttributesDOM,
1212
enableCustomElementPropertySupport,
13+
enableNewBooleanProps,
1314
} from 'shared/ReactFeatureFlags';
1415
import hasOwnProperty from 'shared/hasOwnProperty';
1516

@@ -327,7 +328,7 @@ reservedProps.forEach(name => {
327328
});
328329

329330
// These are HTML boolean attributes.
330-
[
331+
const htmlBooleanAttributes = [
331332
'allowFullScreen',
332333
'async',
333334
// Note: there is a special case that prevents it from being written to the DOM
@@ -342,7 +343,6 @@ reservedProps.forEach(name => {
342343
'disableRemotePlayback',
343344
'formNoValidate',
344345
'hidden',
345-
'inert',
346346
'loop',
347347
'noModule',
348348
'noValidate',
@@ -355,7 +355,13 @@ reservedProps.forEach(name => {
355355
'seamless',
356356
// Microdata
357357
'itemScope',
358-
].forEach(name => {
358+
];
359+
360+
if (enableNewBooleanProps) {
361+
htmlBooleanAttributes.push('inert');
362+
}
363+
364+
htmlBooleanAttributes.forEach(name => {
359365
properties[name] = new PropertyInfoRecord(
360366
name,
361367
BOOLEAN,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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';
78

89
// When adding attributes to the HTML or SVG allowed attribute list, be sure to
910
// also add them to this module to ensure casing and incorrect name
@@ -81,7 +82,6 @@ const possibleStandardNames = {
8182
id: 'id',
8283
imagesizes: 'imageSizes',
8384
imagesrcset: 'imageSrcSet',
84-
inert: 'inert',
8585
innerhtml: 'innerHTML',
8686
inputmode: 'inputMode',
8787
integrity: 'integrity',
@@ -500,4 +500,8 @@ const possibleStandardNames = {
500500
zoomandpan: 'zoomAndPan',
501501
};
502502

503+
if (enableNewBooleanProps) {
504+
possibleStandardNames.inert = 'inert';
505+
}
506+
503507
export default possibleStandardNames;

packages/shared/ReactFeatureFlags.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ export const enableFilterEmptyStringAttributesDOM = false;
179179
// https://github.com/facebook/react/issues/11347
180180
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
181181

182+
// HTML boolean attributes need a special PropertyInfoRecord.
183+
// Between support of these attributes in browsers and React supporting them as
184+
// boolean props library users can use them as `<div someBooleanAttribute="" />`.
185+
// However, once React considers them as boolean props an empty string will
186+
// result in false property i.e. break existing usage.
187+
export const enableNewBooleanProps = __EXPERIMENTAL__;
188+
182189
// Disables children for <textarea> elements
183190
export const disableTextareaChildren = false;
184191

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const enableLegacyHidden = true;
7171
export const enableSyncDefaultUpdates = true;
7272
export const allowConcurrentByDefault = true;
7373
export const enableCustomElementPropertySupport = false;
74+
export const enableNewBooleanProps = false;
7475

7576
export const consoleManagedByDevToolsDuringStrictMode = false;
7677
export const enableServerContext = false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const enableLegacyHidden = false;
6161
export const enableSyncDefaultUpdates = true;
6262
export const allowConcurrentByDefault = false;
6363
export const enableCustomElementPropertySupport = false;
64+
export const enableNewBooleanProps = false;
6465

6566
export const consoleManagedByDevToolsDuringStrictMode = false;
6667
export const enableServerContext = false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const enableLegacyHidden = false;
6161
export const enableSyncDefaultUpdates = true;
6262
export const allowConcurrentByDefault = false;
6363
export const enableCustomElementPropertySupport = false;
64+
export const enableNewBooleanProps = false;
6465

6566
export const consoleManagedByDevToolsDuringStrictMode = false;
6667
export const enableServerContext = false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const enableLegacyHidden = false;
6161
export const enableSyncDefaultUpdates = true;
6262
export const allowConcurrentByDefault = true;
6363
export const enableCustomElementPropertySupport = false;
64+
export const enableNewBooleanProps = false;
6465

6566
export const consoleManagedByDevToolsDuringStrictMode = false;
6667
export const enableServerContext = false;

packages/shared/forks/ReactFeatureFlags.testing.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const enableLegacyHidden = false;
6161
export const enableSyncDefaultUpdates = true;
6262
export const allowConcurrentByDefault = false;
6363
export const enableCustomElementPropertySupport = false;
64+
export const enableNewBooleanProps = false;
6465

6566
export const consoleManagedByDevToolsDuringStrictMode = false;
6667
export const enableServerContext = false;

packages/shared/forks/ReactFeatureFlags.testing.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const enableLegacyHidden = false;
6161
export const enableSyncDefaultUpdates = true;
6262
export const allowConcurrentByDefault = true;
6363
export const enableCustomElementPropertySupport = false;
64+
export const enableNewBooleanProps = false;
6465

6566
export const consoleManagedByDevToolsDuringStrictMode = false;
6667
export const enableServerContext = false;

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ export const enableUseMutableSource = true;
105105

106106
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
107107

108+
export const enableNewBooleanProps = __EXPERIMENTAL__;
109+
108110
export const enableTransitionTracing = false;
109111

110112
export const enableSymbolFallbackForWWW = true;

0 commit comments

Comments
 (0)