Skip to content

Commit b052e93

Browse files
committed
Add support behind enableNewBooleanProps flag
1 parent 3be86f7 commit b052e93

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
@@ -182,6 +182,13 @@ export const enableFilterEmptyStringAttributesDOM = false;
182182
// https://github.com/facebook/react/issues/11347
183183
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
184184

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

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

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

7677
export const consoleManagedByDevToolsDuringStrictMode = false;
7778
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
@@ -62,6 +62,7 @@ export const enableLegacyHidden = false;
6262
export const enableSyncDefaultUpdates = true;
6363
export const allowConcurrentByDefault = false;
6464
export const enableCustomElementPropertySupport = false;
65+
export const enableNewBooleanProps = false;
6566

6667
export const consoleManagedByDevToolsDuringStrictMode = false;
6768
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
@@ -62,6 +62,7 @@ export const enableLegacyHidden = false;
6262
export const enableSyncDefaultUpdates = true;
6363
export const allowConcurrentByDefault = false;
6464
export const enableCustomElementPropertySupport = false;
65+
export const enableNewBooleanProps = false;
6566

6667
export const consoleManagedByDevToolsDuringStrictMode = false;
6768
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
@@ -62,6 +62,7 @@ export const enableLegacyHidden = false;
6262
export const enableSyncDefaultUpdates = true;
6363
export const allowConcurrentByDefault = true;
6464
export const enableCustomElementPropertySupport = false;
65+
export const enableNewBooleanProps = false;
6566

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

packages/shared/forks/ReactFeatureFlags.testing.js

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

6667
export const consoleManagedByDevToolsDuringStrictMode = false;
6768
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
@@ -62,6 +62,7 @@ export const enableLegacyHidden = false;
6262
export const enableSyncDefaultUpdates = true;
6363
export const allowConcurrentByDefault = true;
6464
export const enableCustomElementPropertySupport = false;
65+
export const enableNewBooleanProps = false;
6566

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

packages/shared/forks/ReactFeatureFlags.www.js

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

108108
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
109109

110+
export const enableNewBooleanProps = __EXPERIMENTAL__;
111+
110112
export const enableSymbolFallbackForWWW = true;
111113
// Flow magic to verify the exports of this file match the original version.
112114
// eslint-disable-next-line no-unused-vars

0 commit comments

Comments
 (0)