@@ -65,16 +65,16 @@ export default function useWinClick(
65
65
66
66
const win = getWin ( popupEle ) ;
67
67
68
- win . addEventListener ( 'mousedown' , onWinMouseDown ) ;
69
- win . addEventListener ( 'click' , onWinClick ) ;
70
- win . addEventListener ( 'contextmenu' , onWinClick ) ;
68
+ win . addEventListener ( 'mousedown' , onWinMouseDown , true ) ;
69
+ win . addEventListener ( 'click' , onWinClick , true ) ;
70
+ win . addEventListener ( 'contextmenu' , onWinClick , true ) ;
71
71
72
72
// shadow root
73
73
const targetShadowRoot = getShadowRoot ( targetEle ) ;
74
74
if ( targetShadowRoot ) {
75
- targetShadowRoot . addEventListener ( 'mousedown' , onShadowMouseDown ) ;
76
- targetShadowRoot . addEventListener ( 'click' , onShadowClick ) ;
77
- targetShadowRoot . addEventListener ( 'contextmenu' , onShadowClick ) ;
75
+ targetShadowRoot . addEventListener ( 'mousedown' , onShadowMouseDown , true ) ;
76
+ targetShadowRoot . addEventListener ( 'click' , onShadowClick , true ) ;
77
+ targetShadowRoot . addEventListener ( 'contextmenu' , onShadowClick , true ) ;
78
78
}
79
79
80
80
// Warning if target and popup not in same root
@@ -89,14 +89,22 @@ export default function useWinClick(
89
89
}
90
90
91
91
return ( ) => {
92
- win . removeEventListener ( 'mousedown' , onWinMouseDown ) ;
93
- win . removeEventListener ( 'click' , onWinClick ) ;
94
- win . removeEventListener ( 'contextmenu' , onWinClick ) ;
92
+ win . removeEventListener ( 'mousedown' , onWinMouseDown , true ) ;
93
+ win . removeEventListener ( 'click' , onWinClick , true ) ;
94
+ win . removeEventListener ( 'contextmenu' , onWinClick , true ) ;
95
95
96
96
if ( targetShadowRoot ) {
97
- targetShadowRoot . removeEventListener ( 'mousedown' , onShadowMouseDown ) ;
98
- targetShadowRoot . removeEventListener ( 'click' , onShadowClick ) ;
99
- targetShadowRoot . removeEventListener ( 'contextmenu' , onShadowClick ) ;
97
+ targetShadowRoot . removeEventListener (
98
+ 'mousedown' ,
99
+ onShadowMouseDown ,
100
+ true ,
101
+ ) ;
102
+ targetShadowRoot . removeEventListener ( 'click' , onShadowClick , true ) ;
103
+ targetShadowRoot . removeEventListener (
104
+ 'contextmenu' ,
105
+ onShadowClick ,
106
+ true ,
107
+ ) ;
100
108
}
101
109
} ;
102
110
}
0 commit comments