@@ -420,7 +420,8 @@ describe('DOMPluginEventSystem', () => {
420
420
expect ( log [ 9 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
421
421
} ) ;
422
422
423
- it ( 'handle propagation of click events between disjointed legacy comment roots' , ( ) => {
423
+ // @gate !disableCommentsAsDOMContainers
424
+ it ( 'handle propagation of click events between disjointed comment roots' , async ( ) => {
424
425
const buttonRef = React . createRef ( ) ;
425
426
const divRef = React . createRef ( ) ;
426
427
const log = [ ] ;
@@ -454,19 +455,29 @@ describe('DOMPluginEventSystem', () => {
454
455
const disjointedNode = document . createComment (
455
456
' react-mount-point-unstable ' ,
456
457
) ;
457
- ReactDOM . render ( < Parent /> , container ) ;
458
+ const root = ReactDOMClient . createRoot ( container ) ;
459
+ await act ( ( ) => {
460
+ root . render ( < Parent /> ) ;
461
+ } ) ;
458
462
buttonRef . current . appendChild ( disjointedNode ) ;
459
- ReactDOM . render ( < Child /> , disjointedNode ) ;
463
+ const disjointedNodeRoot = ReactDOMClient . createRoot ( disjointedNode ) ;
464
+ await act ( ( ) => {
465
+ disjointedNodeRoot . render ( < Child /> ) ;
466
+ } ) ;
460
467
461
468
const buttonElement = buttonRef . current ;
462
- dispatchClickEvent ( buttonElement ) ;
469
+ await act ( ( ) => {
470
+ dispatchClickEvent ( buttonElement ) ;
471
+ } ) ;
463
472
expect ( onClick ) . toHaveBeenCalledTimes ( 1 ) ;
464
473
expect ( onClickCapture ) . toHaveBeenCalledTimes ( 1 ) ;
465
474
expect ( log [ 0 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
466
475
expect ( log [ 1 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
467
476
468
477
const divElement = divRef . current ;
469
- dispatchClickEvent ( divElement ) ;
478
+ await act ( ( ) => {
479
+ dispatchClickEvent ( divElement ) ;
480
+ } ) ;
470
481
expect ( onClick ) . toHaveBeenCalledTimes ( 3 ) ;
471
482
expect ( onClickCapture ) . toHaveBeenCalledTimes ( 3 ) ;
472
483
expect ( log [ 2 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
@@ -475,7 +486,8 @@ describe('DOMPluginEventSystem', () => {
475
486
expect ( log [ 5 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
476
487
} ) ;
477
488
478
- it ( 'handle propagation of click events between disjointed legacy comment roots #2' , ( ) => {
489
+ // @gate !disableCommentsAsDOMContainers
490
+ it ( 'handle propagation of click events between disjointed comment roots #2' , async ( ) => {
479
491
const buttonRef = React . createRef ( ) ;
480
492
const divRef = React . createRef ( ) ;
481
493
const spanRef = React . createRef ( ) ;
@@ -511,19 +523,29 @@ describe('DOMPluginEventSystem', () => {
511
523
const disjointedNode = document . createComment (
512
524
' react-mount-point-unstable ' ,
513
525
) ;
514
- ReactDOM . render ( < Parent /> , container ) ;
526
+ const root = ReactDOMClient . createRoot ( container ) ;
527
+ await act ( ( ) => {
528
+ root . render ( < Parent /> ) ;
529
+ } ) ;
515
530
spanRef . current . appendChild ( disjointedNode ) ;
516
- ReactDOM . render ( < Child /> , disjointedNode ) ;
531
+ const disjointedNodeRoot = ReactDOMClient . createRoot ( disjointedNode ) ;
532
+ await act ( ( ) => {
533
+ disjointedNodeRoot . render ( < Child /> ) ;
534
+ } ) ;
517
535
518
536
const buttonElement = buttonRef . current ;
519
- dispatchClickEvent ( buttonElement ) ;
537
+ await act ( ( ) => {
538
+ dispatchClickEvent ( buttonElement ) ;
539
+ } ) ;
520
540
expect ( onClick ) . toHaveBeenCalledTimes ( 1 ) ;
521
541
expect ( onClickCapture ) . toHaveBeenCalledTimes ( 1 ) ;
522
542
expect ( log [ 0 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
523
543
expect ( log [ 1 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
524
544
525
545
const divElement = divRef . current ;
526
- dispatchClickEvent ( divElement ) ;
546
+ await act ( ( ) => {
547
+ dispatchClickEvent ( divElement ) ;
548
+ } ) ;
527
549
expect ( onClick ) . toHaveBeenCalledTimes ( 3 ) ;
528
550
expect ( onClickCapture ) . toHaveBeenCalledTimes ( 3 ) ;
529
551
expect ( log [ 2 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
@@ -2854,8 +2876,8 @@ describe('DOMPluginEventSystem', () => {
2854
2876
document . body . removeChild ( container2 ) ;
2855
2877
} ) ;
2856
2878
2857
- // @gate www
2858
- it ( 'handle propagation of click events between disjointed legacy comment roots' , async ( ) => {
2879
+ // @gate !disableCommentsAsDOMContainers
2880
+ it ( 'handle propagation of click events between disjointed comment roots' , async ( ) => {
2859
2881
const buttonRef = React . createRef ( ) ;
2860
2882
const divRef = React . createRef ( ) ;
2861
2883
const log = [ ] ;
@@ -2902,12 +2924,15 @@ describe('DOMPluginEventSystem', () => {
2902
2924
const disjointedNode = document . createComment (
2903
2925
' react-mount-point-unstable ' ,
2904
2926
) ;
2927
+ const root = ReactDOMClient . createRoot ( container ) ;
2905
2928
await act ( ( ) => {
2906
- ReactDOM . render ( < Parent /> , container ) ;
2929
+ root . render ( < Parent /> ) ;
2907
2930
} ) ;
2908
2931
buttonRef . current . appendChild ( disjointedNode ) ;
2932
+ const disjointedNodeRoot =
2933
+ ReactDOMClient . createRoot ( disjointedNode ) ;
2909
2934
await act ( ( ) => {
2910
- ReactDOM . render ( < Child /> , disjointedNode ) ;
2935
+ disjointedNodeRoot . render ( < Child /> ) ;
2911
2936
} ) ;
2912
2937
2913
2938
const buttonElement = buttonRef . current ;
0 commit comments