Skip to content

Commit

Permalink
Event API: remove isTargetDirectlyWithinEventComponent (#15546)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Apr 30, 2019
1 parent a6e3000 commit ec6691a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 25 deletions.
16 changes: 0 additions & 16 deletions packages/react-dom/src/events/DOMEventResponderSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ describe('DOMEventResponderSystem', () => {
]);
});

it('isTargetDirectlyWithinEventComponent works', () => {
it('isTargetWithinEventResponderScope works', () => {
const buttonRef = React.createRef();
const divRef = React.createRef();
const log = [];
Expand All @@ -720,7 +720,7 @@ describe('DOMEventResponderSystem', () => {
undefined,
undefined,
(event, context) => {
const isWithin = context.isTargetDirectlyWithinEventComponent(
const isWithin = context.isTargetWithinEventResponderScope(
event.nativeEvent.relatedTarget,
);
log.push(isWithin);
Expand Down
4 changes: 0 additions & 4 deletions packages/react-events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions packages/react-events/src/Hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function dispatchHoverStartEvents(
if (event !== null) {
const {nativeEvent} = event;
if (
context.isTargetDirectlyWithinEventComponent(
context.isTargetWithinEventResponderScope(
(nativeEvent: any).relatedTarget,
)
) {
Expand Down Expand Up @@ -157,7 +157,7 @@ function dispatchHoverEndEvents(
if (event !== null) {
const {nativeEvent} = event;
if (
context.isTargetDirectlyWithinEventComponent(
context.isTargetWithinEventResponderScope(
(nativeEvent: any).relatedTarget,
)
) {
Expand Down
1 change: 0 additions & 1 deletion packages/shared/ReactTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
Expand Down

0 comments on commit ec6691a

Please sign in to comment.