Skip to content

Commit

Permalink
Add support behind enableNewBooleanProps flag
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored and Sebastian Silbermann committed Feb 7, 2024
1 parent 5dbdb16 commit 78f1ad6
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
disableIEWorkarounds,
enableTrustedTypesIntegration,
enableFilterEmptyStringAttributesDOM,
enableNewBooleanProps,
} from 'shared/ReactFeatureFlags';
import {
mediaEventTypes,
Expand Down Expand Up @@ -715,7 +716,7 @@ function setProp(
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case 'inert':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand Down Expand Up @@ -2494,6 +2495,7 @@ function diffHydratedGenericElement(
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
enableFloat,
enableFormActions,
enableFizzExternalRuntime,
enableNewBooleanProps,
} from 'shared/ReactFeatureFlags';

import type {
Expand Down Expand Up @@ -1289,6 +1290,7 @@ function pushAttribute(
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import hasOwnProperty from 'shared/hasOwnProperty';
import {
enableCustomElementPropertySupport,
enableFormActions,
enableNewBooleanProps,
} from 'shared/ReactFeatureFlags';

const warnedProperties = {};
Expand Down Expand Up @@ -223,7 +224,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case 'inert':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand Down Expand Up @@ -301,6 +302,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {enableNewBooleanProps} from 'shared/ReactFeatureFlags';

// When adding attributes to the HTML or SVG allowed attribute list, be sure to
// also add them to this module to ensure casing and incorrect name
Expand Down Expand Up @@ -82,7 +83,6 @@ const possibleStandardNames = {
id: 'id',
imagesizes: 'imageSizes',
imagesrcset: 'imageSrcSet',
inert: 'inert',
innerhtml: 'innerHTML',
inputmode: 'inputMode',
integrity: 'integrity',
Expand Down Expand Up @@ -503,4 +503,8 @@ const possibleStandardNames = {
zoomandpan: 'zoomAndPan',
};

if (enableNewBooleanProps) {
possibleStandardNames.inert = 'inert';
}

export default possibleStandardNames;
7 changes: 7 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ export const disableInputAttributeSyncing = false;
// Disables children for <textarea> elements
export const disableTextareaChildren = false;

// HTML boolean attributes need a special PropertyInfoRecord.
// Between support of these attributes in browsers and React supporting them as
// boolean props library users can use them as `<div someBooleanAttribute="" />`.
// However, once React considers them as boolean props an empty string will
// result in false property i.e. break existing usage.
export const enableNewBooleanProps = __EXPERIMENTAL__;

// -----------------------------------------------------------------------------
// Debugging and DevTools
// -----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const enableLegacyHidden = true;
export const forceConcurrentByDefaultForTesting = false;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const forceConcurrentByDefaultForTesting = false;
export const enableUnifiedSyncLane = true;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const forceConcurrentByDefaultForTesting = false;
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const enableLegacyHidden = false;
export const forceConcurrentByDefaultForTesting = false;
export const enableUnifiedSyncLane = true;
export const allowConcurrentByDefault = true;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const forceConcurrentByDefaultForTesting = false;
export const enableUnifiedSyncLane = true;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const enableLazyContextPropagation = __VARIANT__;
export const forceConcurrentByDefaultForTesting = __VARIANT__;
export const enableUnifiedSyncLane = __VARIANT__;
export const enableTransitionTracing = __VARIANT__;
export const enableNewBooleanProps = __VARIANT__;
export const enableDeferRootSchedulingToMicrotask = __VARIANT__;
export const enableAsyncActions = __VARIANT__;
export const enableFormActions = __VARIANT__;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export const allowConcurrentByDefault = true;

export const consoleManagedByDevToolsDuringStrictMode = true;

export const enableNewBooleanProps = __EXPERIMENTAL__;

export const useModernStrictMode = false;
export const enableFizzExternalRuntime = true;

Expand Down

0 comments on commit 78f1ad6

Please sign in to comment.