Skip to content

Commit 09191f6

Browse files
eps1lonSebastian Silbermann
authored andcommitted
Add support behind enableNewBooleanProps flag
1 parent fb08976 commit 09191f6

12 files changed

+28
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
disableIEWorkarounds,
7373
enableTrustedTypesIntegration,
7474
enableFilterEmptyStringAttributesDOM,
75+
enableNewBooleanProps,
7576
} from 'shared/ReactFeatureFlags';
7677
import {
7778
mediaEventTypes,
@@ -711,7 +712,7 @@ function setProp(
711712
case 'disableRemotePlayback':
712713
case 'formNoValidate':
713714
case 'hidden':
714-
case 'inert':
715+
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
715716
case 'loop':
716717
case 'noModule':
717718
case 'noValidate':
@@ -2486,6 +2487,7 @@ function diffHydratedGenericElement(
24862487
case 'disableRemotePlayback':
24872488
case 'formNoValidate':
24882489
case 'hidden':
2490+
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
24892491
case 'loop':
24902492
case 'noModule':
24912493
case 'noValidate':

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
enableFloat,
3434
enableFormActions,
3535
enableFizzExternalRuntime,
36+
enableNewBooleanProps,
3637
} from 'shared/ReactFeatureFlags';
3738

3839
import type {
@@ -1294,6 +1295,7 @@ function pushAttribute(
12941295
case 'disableRemotePlayback':
12951296
case 'formNoValidate':
12961297
case 'hidden':
1298+
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
12971299
case 'loop':
12981300
case 'noModule':
12991301
case 'noValidate':

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import hasOwnProperty from 'shared/hasOwnProperty';
1212
import {
1313
enableCustomElementPropertySupport,
1414
enableFormActions,
15+
enableNewBooleanProps,
1516
} from 'shared/ReactFeatureFlags';
1617

1718
const warnedProperties = {};
@@ -223,7 +224,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
223224
case 'disableRemotePlayback':
224225
case 'formNoValidate':
225226
case 'hidden':
226-
case 'inert':
227+
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
227228
case 'loop':
228229
case 'noModule':
229230
case 'noValidate':
@@ -301,6 +302,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
301302
case 'disableRemotePlayback':
302303
case 'formNoValidate':
303304
case 'hidden':
305+
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
304306
case 'loop':
305307
case 'noModule':
306308
case 'noValidate':

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
@@ -196,6 +196,13 @@ export const enableFilterEmptyStringAttributesDOM = __EXPERIMENTAL__;
196196
// https://github.com/facebook/react/issues/11347
197197
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
198198

199+
// HTML boolean attributes need a special PropertyInfoRecord.
200+
// Between support of these attributes in browsers and React supporting them as
201+
// boolean props library users can use them as `<div someBooleanAttribute="" />`.
202+
// However, once React considers them as boolean props an empty string will
203+
// result in false property i.e. break existing usage.
204+
export const enableNewBooleanProps = __EXPERIMENTAL__;
205+
199206
// Disables children for <textarea> elements
200207
export const disableTextareaChildren = false;
201208

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const enableLegacyHidden = true;
8181
export const forceConcurrentByDefaultForTesting = false;
8282
export const allowConcurrentByDefault = true;
8383
export const enableCustomElementPropertySupport = false;
84+
export const enableNewBooleanProps = false;
8485

8586
export const consoleManagedByDevToolsDuringStrictMode = false;
8687
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
@@ -66,6 +66,7 @@ export const forceConcurrentByDefaultForTesting = false;
6666
export const enableUnifiedSyncLane = true;
6767
export const allowConcurrentByDefault = false;
6868
export const enableCustomElementPropertySupport = false;
69+
export const enableNewBooleanProps = false;
6970

7071
export const consoleManagedByDevToolsDuringStrictMode = false;
7172
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
@@ -66,6 +66,7 @@ export const forceConcurrentByDefaultForTesting = false;
6666
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
6767
export const allowConcurrentByDefault = false;
6868
export const enableCustomElementPropertySupport = false;
69+
export const enableNewBooleanProps = false;
6970

7071
export const consoleManagedByDevToolsDuringStrictMode = false;
7172
export const enableServerContext = false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const enableLegacyHidden = false;
6464
export const forceConcurrentByDefaultForTesting = false;
6565
export const enableUnifiedSyncLane = true;
6666
export const allowConcurrentByDefault = true;
67+
export const enableNewBooleanProps = false;
6768

6869
export const consoleManagedByDevToolsDuringStrictMode = false;
6970
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
@@ -66,6 +66,7 @@ export const forceConcurrentByDefaultForTesting = false;
6666
export const enableUnifiedSyncLane = true;
6767
export const allowConcurrentByDefault = true;
6868
export const enableCustomElementPropertySupport = false;
69+
export const enableNewBooleanProps = false;
6970

7071
export const consoleManagedByDevToolsDuringStrictMode = false;
7172
export const enableServerContext = false;

0 commit comments

Comments
 (0)