@@ -420,7 +420,8 @@ describe('DOMPluginEventSystem', () => {
420420 expect ( log [ 9 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
421421 } ) ;
422422
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 ( ) => {
424425 const buttonRef = React . createRef ( ) ;
425426 const divRef = React . createRef ( ) ;
426427 const log = [ ] ;
@@ -454,19 +455,29 @@ describe('DOMPluginEventSystem', () => {
454455 const disjointedNode = document . createComment (
455456 ' react-mount-point-unstable ' ,
456457 ) ;
457- ReactDOM . render ( < Parent /> , container ) ;
458+ const root = ReactDOMClient . createRoot ( container ) ;
459+ await act ( ( ) => {
460+ root . render ( < Parent /> ) ;
461+ } ) ;
458462 buttonRef . current . appendChild ( disjointedNode ) ;
459- ReactDOM . render ( < Child /> , disjointedNode ) ;
463+ const disjointedNodeRoot = ReactDOMClient . createRoot ( disjointedNode ) ;
464+ await act ( ( ) => {
465+ disjointedNodeRoot . render ( < Child /> ) ;
466+ } ) ;
460467
461468 const buttonElement = buttonRef . current ;
462- dispatchClickEvent ( buttonElement ) ;
469+ await act ( ( ) => {
470+ dispatchClickEvent ( buttonElement ) ;
471+ } ) ;
463472 expect ( onClick ) . toHaveBeenCalledTimes ( 1 ) ;
464473 expect ( onClickCapture ) . toHaveBeenCalledTimes ( 1 ) ;
465474 expect ( log [ 0 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
466475 expect ( log [ 1 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
467476
468477 const divElement = divRef . current ;
469- dispatchClickEvent ( divElement ) ;
478+ await act ( ( ) => {
479+ dispatchClickEvent ( divElement ) ;
480+ } ) ;
470481 expect ( onClick ) . toHaveBeenCalledTimes ( 3 ) ;
471482 expect ( onClickCapture ) . toHaveBeenCalledTimes ( 3 ) ;
472483 expect ( log [ 2 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
@@ -475,7 +486,8 @@ describe('DOMPluginEventSystem', () => {
475486 expect ( log [ 5 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
476487 } ) ;
477488
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 ( ) => {
479491 const buttonRef = React . createRef ( ) ;
480492 const divRef = React . createRef ( ) ;
481493 const spanRef = React . createRef ( ) ;
@@ -511,19 +523,29 @@ describe('DOMPluginEventSystem', () => {
511523 const disjointedNode = document . createComment (
512524 ' react-mount-point-unstable ' ,
513525 ) ;
514- ReactDOM . render ( < Parent /> , container ) ;
526+ const root = ReactDOMClient . createRoot ( container ) ;
527+ await act ( ( ) => {
528+ root . render ( < Parent /> ) ;
529+ } ) ;
515530 spanRef . current . appendChild ( disjointedNode ) ;
516- ReactDOM . render ( < Child /> , disjointedNode ) ;
531+ const disjointedNodeRoot = ReactDOMClient . createRoot ( disjointedNode ) ;
532+ await act ( ( ) => {
533+ disjointedNodeRoot . render ( < Child /> ) ;
534+ } ) ;
517535
518536 const buttonElement = buttonRef . current ;
519- dispatchClickEvent ( buttonElement ) ;
537+ await act ( ( ) => {
538+ dispatchClickEvent ( buttonElement ) ;
539+ } ) ;
520540 expect ( onClick ) . toHaveBeenCalledTimes ( 1 ) ;
521541 expect ( onClickCapture ) . toHaveBeenCalledTimes ( 1 ) ;
522542 expect ( log [ 0 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
523543 expect ( log [ 1 ] ) . toEqual ( [ 'bubble' , buttonElement ] ) ;
524544
525545 const divElement = divRef . current ;
526- dispatchClickEvent ( divElement ) ;
546+ await act ( ( ) => {
547+ dispatchClickEvent ( divElement ) ;
548+ } ) ;
527549 expect ( onClick ) . toHaveBeenCalledTimes ( 3 ) ;
528550 expect ( onClickCapture ) . toHaveBeenCalledTimes ( 3 ) ;
529551 expect ( log [ 2 ] ) . toEqual ( [ 'capture' , buttonElement ] ) ;
@@ -2854,8 +2876,8 @@ describe('DOMPluginEventSystem', () => {
28542876 document . body . removeChild ( container2 ) ;
28552877 } ) ;
28562878
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 ( ) => {
28592881 const buttonRef = React . createRef ( ) ;
28602882 const divRef = React . createRef ( ) ;
28612883 const log = [ ] ;
@@ -2902,12 +2924,15 @@ describe('DOMPluginEventSystem', () => {
29022924 const disjointedNode = document . createComment (
29032925 ' react-mount-point-unstable ' ,
29042926 ) ;
2927+ const root = ReactDOMClient . createRoot ( container ) ;
29052928 await act ( ( ) => {
2906- ReactDOM . render ( < Parent /> , container ) ;
2929+ root . render ( < Parent /> ) ;
29072930 } ) ;
29082931 buttonRef . current . appendChild ( disjointedNode ) ;
2932+ const disjointedNodeRoot =
2933+ ReactDOMClient . createRoot ( disjointedNode ) ;
29092934 await act ( ( ) => {
2910- ReactDOM . render ( < Child /> , disjointedNode ) ;
2935+ disjointedNodeRoot . render ( < Child /> ) ;
29112936 } ) ;
29122937
29132938 const buttonElement = buttonRef . current ;
0 commit comments