File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 10
10
import {
11
11
enableFilterEmptyStringAttributesDOM ,
12
12
enableCustomElementPropertySupport ,
13
+ enableNewBooleanProps ,
13
14
} from 'shared/ReactFeatureFlags' ;
14
15
import hasOwnProperty from 'shared/hasOwnProperty' ;
15
16
@@ -327,7 +328,7 @@ reservedProps.forEach(name => {
327
328
} ) ;
328
329
329
330
// These are HTML boolean attributes.
330
- [
331
+ const htmlBooleanAttributes = [
331
332
'allowFullScreen' ,
332
333
'async' ,
333
334
// Note: there is a special case that prevents it from being written to the DOM
@@ -342,7 +343,6 @@ reservedProps.forEach(name => {
342
343
'disableRemotePlayback' ,
343
344
'formNoValidate' ,
344
345
'hidden' ,
345
- 'inert' ,
346
346
'loop' ,
347
347
'noModule' ,
348
348
'noValidate' ,
@@ -355,7 +355,13 @@ reservedProps.forEach(name => {
355
355
'seamless' ,
356
356
// Microdata
357
357
'itemScope' ,
358
- ] . forEach ( name => {
358
+ ] ;
359
+
360
+ if ( enableNewBooleanProps ) {
361
+ htmlBooleanAttributes . push ( 'inert' ) ;
362
+ }
363
+
364
+ htmlBooleanAttributes . forEach ( name => {
359
365
properties [ name ] = new PropertyInfoRecord (
360
366
name ,
361
367
BOOLEAN ,
Original file line number Diff line number Diff line change 4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
6
6
*/
7
+ import { enableNewBooleanProps } from 'shared/ReactFeatureFlags' ;
7
8
8
9
// When adding attributes to the HTML or SVG allowed attribute list, be sure to
9
10
// also add them to this module to ensure casing and incorrect name
@@ -81,7 +82,6 @@ const possibleStandardNames = {
81
82
id : 'id' ,
82
83
imagesizes : 'imageSizes' ,
83
84
imagesrcset : 'imageSrcSet' ,
84
- inert : 'inert' ,
85
85
innerhtml : 'innerHTML' ,
86
86
inputmode : 'inputMode' ,
87
87
integrity : 'integrity' ,
@@ -500,4 +500,8 @@ const possibleStandardNames = {
500
500
zoomandpan : 'zoomAndPan' ,
501
501
} ;
502
502
503
+ if ( enableNewBooleanProps ) {
504
+ possibleStandardNames . inert = 'inert' ;
505
+ }
506
+
503
507
export default possibleStandardNames ;
Original file line number Diff line number Diff line change @@ -179,6 +179,13 @@ export const enableFilterEmptyStringAttributesDOM = false;
179
179
// https://github.com/facebook/react/issues/11347
180
180
export const enableCustomElementPropertySupport = __EXPERIMENTAL__ ;
181
181
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
+
182
189
// Disables children for <textarea> elements
183
190
export const disableTextareaChildren = false ;
184
191
You can’t perform that action at this time.
0 commit comments