Skip to content

Commit 271112e

Browse files
committed
Update index.tsx
1 parent 1a764b1 commit 271112e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export function generateTrigger(
272272
const originChildProps = child?.props || {};
273273
const cloneProps: typeof originChildProps = {};
274274

275-
const inContainer = (container: Element, target: Element) => {
275+
const inContainer = (target: Element, container: Element) => {
276276
return (
277277
target === container ||
278278
container.contains(target) ||
@@ -283,13 +283,12 @@ export function generateTrigger(
283283

284284
const inPopupOrChild = useEvent((ele: EventTarget) => {
285285
const childDOM = targetEle;
286+
const eleInContainer = inContainer.bind(null, ele as Element);
286287

287288
return (
288-
inContainer(childDOM, ele as Element) ||
289-
inContainer(popupEle, ele as Element) ||
290-
Object.values(subPopupElements.current).some((subPopupEle) =>
291-
inContainer(subPopupEle, ele as Element),
292-
)
289+
eleInContainer(childDOM) ||
290+
eleInContainer(popupEle) ||
291+
Object.values(subPopupElements.current).some(eleInContainer)
293292
);
294293
});
295294

0 commit comments

Comments
 (0)