diff --git a/packages/react-dom/src/events/DOMEventResponderSystem.js b/packages/react-dom/src/events/DOMEventResponderSystem.js index 4e9b2396950d5..803ad9652c06b 100644 --- a/packages/react-dom/src/events/DOMEventResponderSystem.js +++ b/packages/react-dom/src/events/DOMEventResponderSystem.js @@ -176,22 +176,6 @@ const eventResponderContext: ReactResponderContext = { } return false; }, - isTargetDirectlyWithinEventComponent(target: Element | Document): boolean { - validateResponderContext(); - if (target != null) { - let fiber = getClosestInstanceFromNode(target); - while (fiber !== null) { - if (fiber.stateNode === currentInstance) { - return true; - } - if (fiber.tag === EventComponent) { - return false; - } - fiber = fiber.return; - } - } - return false; - }, isTargetWithinEventResponderScope(target: Element | Document): boolean { validateResponderContext(); const responder = ((currentInstance: any): ReactEventComponentInstance) diff --git a/packages/react-dom/src/events/__tests__/DOMEventResponderSystem-test.internal.js b/packages/react-dom/src/events/__tests__/DOMEventResponderSystem-test.internal.js index 4b0d16743592a..dc5e8c58d2d68 100644 --- a/packages/react-dom/src/events/__tests__/DOMEventResponderSystem-test.internal.js +++ b/packages/react-dom/src/events/__tests__/DOMEventResponderSystem-test.internal.js @@ -710,7 +710,7 @@ describe('DOMEventResponderSystem', () => { ]); }); - it('isTargetDirectlyWithinEventComponent works', () => { + it('isTargetWithinEventResponderScope works', () => { const buttonRef = React.createRef(); const divRef = React.createRef(); const log = []; @@ -720,7 +720,7 @@ describe('DOMEventResponderSystem', () => { undefined, undefined, (event, context) => { - const isWithin = context.isTargetDirectlyWithinEventComponent( + const isWithin = context.isTargetWithinEventResponderScope( event.nativeEvent.relatedTarget, ); log.push(isWithin); diff --git a/packages/react-events/README.md b/packages/react-events/README.md index 744c0b87153c1..4d0694f2e2e12 100644 --- a/packages/react-events/README.md +++ b/packages/react-events/README.md @@ -134,10 +134,6 @@ Returns `true` if the instance has taken ownership of the responder. Returns `true` if the global coordinates lie within the TouchHitTarget. -### isTargetDirectlyWithinEventComponent(target: Element): boolean - -Returns `true` is the target element is within the direct subtree of the Event Component instance, i.e., the target is not nested within an Event Component instance that is a descendant of the current instance. - ### isTargetWithinElement(target: Element, element: Element): boolean Returns `true` if `target` is a child of `element`. diff --git a/packages/react-events/src/Hover.js b/packages/react-events/src/Hover.js index 36b86bdd958e9..f454601b696fb 100644 --- a/packages/react-events/src/Hover.js +++ b/packages/react-events/src/Hover.js @@ -98,7 +98,7 @@ function dispatchHoverStartEvents( if (event !== null) { const {nativeEvent} = event; if ( - context.isTargetDirectlyWithinEventComponent( + context.isTargetWithinEventResponderScope( (nativeEvent: any).relatedTarget, ) ) { @@ -157,7 +157,7 @@ function dispatchHoverEndEvents( if (event !== null) { const {nativeEvent} = event; if ( - context.isTargetDirectlyWithinEventComponent( + context.isTargetWithinEventResponderScope( (nativeEvent: any).relatedTarget, ) ) { diff --git a/packages/shared/ReactTypes.js b/packages/shared/ReactTypes.js index 72d66cd38106e..3fb4c46cea32d 100644 --- a/packages/shared/ReactTypes.js +++ b/packages/shared/ReactTypes.js @@ -172,7 +172,6 @@ export type ReactResponderContext = { parentTarget: Element | Document, ) => boolean, isTargetWithinEventComponent: (Element | Document) => boolean, - isTargetDirectlyWithinEventComponent: (Element | Document) => boolean, isTargetWithinEventResponderScope: (Element | Document) => boolean, isPositionWithinTouchHitTarget: (x: number, y: number) => boolean, addRootEventTypes: (