mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix onGot/LostPointerCapture events (#19487)
This commit is contained in:
@@ -347,8 +347,7 @@ describe('ReactDOMEventListener', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: this has regressed. Fix me.
|
||||
it.skip('onGotPointerCapture', () => {
|
||||
it('onGotPointerCapture', () => {
|
||||
testNativeBubblingEvent({
|
||||
type: 'div',
|
||||
reactEvent: 'onGotPointerCapture',
|
||||
@@ -413,8 +412,7 @@ describe('ReactDOMEventListener', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: this has regressed. Fix me.
|
||||
it.skip('onLostPointerCapture', () => {
|
||||
it('onLostPointerCapture', () => {
|
||||
testNativeBubblingEvent({
|
||||
type: 'div',
|
||||
reactEvent: 'onLostPointerCapture',
|
||||
|
||||
+9
-2
@@ -470,8 +470,15 @@ export function listenToReactEvent(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Check if the react event ends in "Capture"
|
||||
const isCapturePhaseListener = reactEvent.substr(-7) === 'Capture';
|
||||
const isCapturePhaseListener =
|
||||
reactEvent.substr(-7) === 'Capture' &&
|
||||
// Edge case: onGotPointerCapture and onLostPointerCapture
|
||||
// end with "Capture" but that's part of their event names.
|
||||
// The Capture versions would end with CaptureCapture.
|
||||
// So we have to check against that.
|
||||
// This check works because none of the events we support
|
||||
// end with "Pointer".
|
||||
reactEvent.substr(-14, 7) !== 'Pointer';
|
||||
listenToNativeEvent(
|
||||
dependencies[0],
|
||||
isCapturePhaseListener,
|
||||
|
||||
Reference in New Issue
Block a user