File size: 563 Bytes
bc20498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { getElementByMeltId, isElement, isHTMLLabelElement } from './index.js';
export function createClickOutsideIgnore(meltId) {
    return (e) => {
        const target = e.target;
        const triggerEl = getElementByMeltId(meltId);
        if (!triggerEl || !isElement(target))
            return false;
        const id = triggerEl.id;
        if (isHTMLLabelElement(target) && id === target.htmlFor) {
            return true;
        }
        if (target.closest(`label[for="${id}"]`)) {
            return true;
        }
        return false;
    };
}