2024-08-26 21:42:56 +08:00
|
|
|
/**
|
2025-02-25 22:07:56 +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.
|
2024-08-26 21:42:56 +08:00
|
|
|
*/
|
2024-08-26 20:54:20 +08:00
|
|
|
export function getPopupContainer(node?: HTMLElement): HTMLElement {
|
2025-02-25 22:07:56 +08:00
|
|
|
return (
|
|
|
|
node?.closest('form') ?? (node?.parentNode as HTMLElement) ?? document.body
|
|
|
|
);
|
2024-08-26 20:54:20 +08:00
|
|
|
}
|