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 Jun 16, 2022
1 parent a3c152f commit 0f967dc
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/react-dom/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 @@ -327,7 +328,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 @@ -342,7 +343,6 @@ reservedProps.forEach(name => {
'disableRemotePlayback',
'formNoValidate',
'hidden',
'inert',
'loop',
'noModule',
'noValidate',
Expand All @@ -355,7 +355,13 @@ reservedProps.forEach(name => {
'seamless',
// Microdata
'itemScope',
].forEach(name => {
];

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

htmlBooleanAttributes.forEach(name => {
properties[name] = new PropertyInfoRecord(
name,
BOOLEAN,
Expand Down
6 changes: 5 additions & 1 deletion packages/react-dom/src/shared/possibleStandardNames.js
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 @@ -81,7 +82,6 @@ const possibleStandardNames = {
id: 'id',
imagesizes: 'imageSizes',
imagesrcset: 'imageSrcSet',
inert: 'inert',
innerhtml: 'innerHTML',
inputmode: 'inputMode',
integrity: 'integrity',
Expand Down Expand Up @@ -500,4 +500,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 @@ -179,6 +179,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 enableLegacyHidden = true;
export const enableSyncDefaultUpdates = true;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;
export const enableNewBooleanProps = false;

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

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

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

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

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

export const consoleManagedByDevToolsDuringStrictMode = false;
export const enableServerContext = false;
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 @@ -105,6 +105,8 @@ export const enableUseMutableSource = true;

export const enableCustomElementPropertySupport = __EXPERIMENTAL__;

export const enableNewBooleanProps = __EXPERIMENTAL__;

export const enableTransitionTracing = false;

export const enableSymbolFallbackForWWW = true;
Expand Down

0 comments on commit 0f967dc

Please sign in to comment.