Fix onGot/LostPointerCapture events (#19487)

This commit is contained in:
Dan Abramov
2020-07-29 21:54:48 +01:00
committed by GitHub
parent eae90cdbe9
commit dff97a6915
2 changed files with 11 additions and 6 deletions
@@ -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
View File
@@ -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,