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 committed Feb 11, 2023
1 parent bfb6721 commit bb88c83
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/react-dom-bindings/src/shared/DOMProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import {
enableFilterEmptyStringAttributesDOM,
enableCustomElementPropertySupport,
enableNewBooleanProps,
} from 'shared/ReactFeatureFlags';
import hasOwnProperty from 'shared/hasOwnProperty';

Expand Down Expand Up @@ -331,7 +332,7 @@ reservedProps.forEach(name => {
});

// These are HTML boolean attributes.
[
const htmlBooleanAttributes = [
'allowFullScreen',
'async',
// Note: there is a special case that prevents it from being written to the DOM
Expand All @@ -346,7 +347,6 @@ reservedProps.forEach(name => {
'disableRemotePlayback',
'formNoValidate',
'hidden',
'inert',
'loop',
'noModule',
'noValidate',
Expand All @@ -359,7 +359,13 @@ reservedProps.forEach(name => {
'seamless',
// Microdata
'itemScope',
].forEach(name => {
];

if (enableNewBooleanProps) {
htmlBooleanAttributes.push('inert');
}

htmlBooleanAttributes.forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
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 @@ -183,6 +183,13 @@ export const enableFilterEmptyStringAttributesDOM = false;
// https://github.com/facebook/react/issues/11347
export const enableCustomElementPropertySupport = __EXPERIMENTAL__;

// 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__;

// Disables children for <textarea> elements
export const disableTextareaChildren = false;

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 @@ -71,6 +71,7 @@ export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = false;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;
export const enableServerContext = true;
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 @@ -62,6 +62,7 @@ export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = false;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;
export const enableServerContext = true;
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 @@ -62,6 +62,7 @@ export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

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

export const consoleManagedByDevToolsDuringStrictMode = false;
export const enableServerContext = true;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;
export const enableServerContext = true;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.testing.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

export const consoleManagedByDevToolsDuringStrictMode = false;
export const enableServerContext = true;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const enableServerContext = true;
export const enableUseMutableSource = true;

export const enableCustomElementPropertySupport = __EXPERIMENTAL__;
export const enableNewBooleanProps = __EXPERIMENTAL__;

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

0 comments on commit bb88c83

Please sign in to comment.