File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import {
1111 enableFilterEmptyStringAttributesDOM ,
1212 enableCustomElementPropertySupport ,
13+ enableNewBooleanProps ,
1314} from 'shared/ReactFeatureFlags' ;
1415import hasOwnProperty from 'shared/hasOwnProperty' ;
1516
@@ -327,7 +328,7 @@ reservedProps.forEach(name => {
327328} ) ;
328329
329330// These are HTML boolean attributes.
330- [
331+ const htmlBooleanAttributes = [
331332 'allowFullScreen' ,
332333 'async' ,
333334 // Note: there is a special case that prevents it from being written to the DOM
@@ -342,7 +343,6 @@ reservedProps.forEach(name => {
342343 'disableRemotePlayback' ,
343344 'formNoValidate' ,
344345 'hidden' ,
345- 'inert' ,
346346 'loop' ,
347347 'noModule' ,
348348 'noValidate' ,
@@ -355,7 +355,13 @@ reservedProps.forEach(name => {
355355 'seamless' ,
356356 // Microdata
357357 'itemScope' ,
358- ] . forEach ( name => {
358+ ] ;
359+
360+ if ( enableNewBooleanProps ) {
361+ htmlBooleanAttributes . push ( 'inert' ) ;
362+ }
363+
364+ htmlBooleanAttributes . forEach ( name => {
359365 properties [ name ] = new PropertyInfoRecord (
360366 name ,
361367 BOOLEAN ,
Original file line number Diff line number Diff line change 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
@@ -81,7 +82,6 @@ const possibleStandardNames = {
8182 id : 'id' ,
8283 imagesizes : 'imageSizes' ,
8384 imagesrcset : 'imageSrcSet' ,
84- inert : 'inert' ,
8585 innerhtml : 'innerHTML' ,
8686 inputmode : 'inputMode' ,
8787 integrity : 'integrity' ,
@@ -500,4 +500,8 @@ const possibleStandardNames = {
500500 zoomandpan : 'zoomAndPan' ,
501501} ;
502502
503+ if ( enableNewBooleanProps ) {
504+ possibleStandardNames . inert = 'inert' ;
505+ }
506+
503507export default possibleStandardNames ;
Original file line number Diff line number Diff line change @@ -179,6 +179,13 @@ export const enableFilterEmptyStringAttributesDOM = false;
179179// https://github.com/facebook/react/issues/11347
180180export const enableCustomElementPropertySupport = __EXPERIMENTAL__ ;
181181
182+ // HTML boolean attributes need a special PropertyInfoRecord.
183+ // Between support of these attributes in browsers and React supporting them as
184+ // boolean props library users can use them as `<div someBooleanAttribute="" />`.
185+ // However, once React considers them as boolean props an empty string will
186+ // result in false property i.e. break existing usage.
187+ export const enableNewBooleanProps = __EXPERIMENTAL__
188+
182189// Disables children for <textarea> elements
183190export const disableTextareaChildren = false ;
184191
You can’t perform that action at this time.
0 commit comments