File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
packages/react-dom/src/__tests__ Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1040,6 +1040,25 @@ describe('ReactDOMFiber', () => {
10401040 expect ( ops ) . toEqual ( [ ] ) ;
10411041 } ) ;
10421042
1043+ it ( 'listens to events that do not exist in the Portal subtree' , ( ) => {
1044+ const container = document . createElement ( 'div' ) ;
1045+ const onClick = jest . fn ( ) ;
1046+
1047+ const ref = React . createRef ( ) ;
1048+ ReactDOM . render (
1049+ < div onClick = { onClick } >
1050+ { ReactDOM . createPortal ( < button ref = { ref } > click</ button > , document . body ) }
1051+ </ div > ,
1052+ container ,
1053+ ) ;
1054+ const event = new MouseEvent ( 'click' , {
1055+ bubbles : true ,
1056+ } ) ;
1057+ ref . current . dispatchEvent ( event ) ;
1058+
1059+ expect ( onClick ) . toHaveBeenCalledTimes ( 1 ) ; // 0
1060+ } ) ;
1061+
10431062 it ( 'should throw on bad createPortal argument' , ( ) => {
10441063 expect ( ( ) => {
10451064 ReactDOM . createPortal ( < div > portal</ div > , null ) ;
You can’t perform that action at this time.
0 commit comments