Skip to content

Commit a98d185

Browse files
committed
Add support behind enableNewBooleanProps flag
1 parent bfb6721 commit a98d185

10 files changed

+29
-4
lines changed

packages/react-dom-bindings/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

@@ -331,7 +332,7 @@ reservedProps.forEach(name => {
331332
});
332333

333334
// These are HTML boolean attributes.
334-
[
335+
const htmlBooleanAttributes = [
335336
'allowFullScreen',
336337
'async',
337338
// Note: there is a special case that prevents it from being written to the DOM
@@ -346,7 +347,6 @@ reservedProps.forEach(name => {
346347
'disableRemotePlayback',
347348
'formNoValidate',
348349
'hidden',
349-
'inert',
350350
'loop',
351351
'noModule',
352352
'noValidate',
@@ -359,7 +359,13 @@ reservedProps.forEach(name => {
359359
'seamless',
360360
// Microdata
361361
'itemScope',
362-
].forEach(name => {
362+
];
363+
364+
if (enableNewBooleanProps) {
365+
htmlBooleanAttributes.push('inert');
366+
}
367+
368+
htmlBooleanAttributes.forEach(name => {
363369
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
364370
properties[name] = new PropertyInfoRecord(
365371
name,

packages/react-dom-bindings/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
@@ -82,7 +83,6 @@ const possibleStandardNames = {
8283
id: 'id',
8384
imagesizes: 'imageSizes',
8485
imagesrcset: 'imageSrcSet',
85-
inert: 'inert',
8686
innerhtml: 'innerHTML',
8787
inputmode: 'inputMode',
8888
integrity: 'integrity',
@@ -503,4 +503,8 @@ const possibleStandardNames = {
503503
zoomandpan: 'zoomAndPan',
504504
};
505505

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

packages/shared/ReactFeatureFlags.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ export const enableFilterEmptyStringAttributesDOM = false;
183183
// https://github.com/facebook/react/issues/11347
184184
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
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 = __EXPERIMENTAL__;
192+
186193
// Disables children for <textarea> elements
187194
export const disableTextareaChildren = false;
188195

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 enableSyncDefaultUpdates = true;
7171
export const enableUnifiedSyncLane = false;
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 = true;

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 enableSyncDefaultUpdates = true;
6262
export const enableUnifiedSyncLane = false;
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 = true;

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 enableSyncDefaultUpdates = true;
6262
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
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 = true;

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 enableSyncDefaultUpdates = true;
6262
export const enableUnifiedSyncLane = false;
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 = true;

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 enableSyncDefaultUpdates = true;
6262
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
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 = true;

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 enableSyncDefaultUpdates = true;
6262
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
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 = true;

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ export const enableServerContext = true;
101101
export const enableUseMutableSource = true;
102102

103103
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
104+
export const enableNewBooleanProps = __EXPERIMENTAL__;
104105

105106
export const useModernStrictMode = false;
106107
export const enableFizzExternalRuntime = true;
107108

109+
108110
// Flow magic to verify the exports of this file match the original version.
109111
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

0 commit comments

Comments
 (0)