File tree Expand file tree Collapse file tree
Libraries/NativeComponent
src/private/renderer/core/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,6 +112,18 @@ const bubblingEventTypes = {
112112 bubbled : 'onPointerOver' ,
113113 } ,
114114 } ,
115+ topGotPointerCapture : {
116+ phasedRegistrationNames : {
117+ captured : 'onGotPointerCaptureCapture' ,
118+ bubbled : 'onGotPointerCapture' ,
119+ } ,
120+ } ,
121+ topLostPointerCapture : {
122+ phasedRegistrationNames : {
123+ captured : 'onLostPointerCaptureCapture' ,
124+ bubbled : 'onLostPointerCapture' ,
125+ } ,
126+ } ,
115127 topClick : {
116128 phasedRegistrationNames : {
117129 captured : 'onClickCapture' ,
@@ -424,6 +436,10 @@ const validAttributesForEventProps = {
424436 onPointerOutCapture : true ,
425437 onPointerOver : true ,
426438 onPointerOverCapture : true ,
439+ onGotPointerCapture : true ,
440+ onGotPointerCaptureCapture : true ,
441+ onLostPointerCapture : true ,
442+ onLostPointerCaptureCapture : true ,
427443} as const ;
428444
429445/**
Original file line number Diff line number Diff line change @@ -157,6 +157,58 @@ describe('Event Dispatching', () => {
157157 expect ( onPointerUpPriority ) . toBe ( UIManager . unstable_DiscreteEventPriority ) ;
158158 } ) ;
159159
160+ it ( 'dispatches pointer capture events' , ( ) => {
161+ const root = Fantom . createRoot ( ) ;
162+
163+ const ref = React . createRef < React . ElementRef < typeof View >> ( ) ;
164+ const order : Array < string > = [];
165+
166+ Fantom.runTask(() => {
167+ root . render (
168+ < View
169+ ref = { ref }
170+ onGotPointerCaptureCapture = { ( ) => {
171+ order . push ( 'got-capture' ) ;
172+ } }
173+ onGotPointerCapture = { ( ) => {
174+ order . push ( 'got-bubble' ) ;
175+ } }
176+ onLostPointerCaptureCapture = { ( ) => {
177+ order . push ( 'lost-capture' ) ;
178+ } }
179+ onLostPointerCapture = { ( ) => {
180+ order . push ( 'lost-bubble' ) ;
181+ } }
182+ /> ,
183+ ) ;
184+ } );
185+
186+ Fantom.dispatchNativeEvent(
187+ ref,
188+ 'onGotPointerCapture',
189+ { pointerId : 1 } ,
190+ {
191+ category : Fantom . NativeEventCategory . Discrete ,
192+ } ,
193+ );
194+
195+ Fantom.dispatchNativeEvent(
196+ ref,
197+ 'onLostPointerCapture',
198+ { pointerId : 1 } ,
199+ {
200+ category : Fantom . NativeEventCategory . Discrete ,
201+ } ,
202+ );
203+
204+ expect(order).toEqual([
205+ 'got-capture',
206+ 'got-bubble',
207+ 'lost-capture',
208+ 'lost-bubble',
209+ ]);
210+ } ) ;
211+
160212 it ( 'dispatches events with continuous priority' , ( ) => {
161213 const root = Fantom . createRoot ( ) ;
162214
You can’t perform that action at this time.
0 commit comments