Files
xfc__adminfront_V2/packages/utils/src/helpers/get-popup-container.ts

11 lines
354 B
TypeScript
Raw Normal View History

2026-01-30 16:03:46 +08:00
/**
* If the node is holding inside a form, return the form element,
* otherwise return the parent node of the given element or
* the document body if the element is not provided.
*/
export function getPopupContainer(node?: HTMLElement): HTMLElement {
return (
node?.closest('form') ?? (node?.parentNode as HTMLElement) ?? document.body
);
}