import { DomDatasetBoolean } from '../types'; export function contains(current?: Node, target?: Node) { if (!current || !target) return false; if (current === target) return true; let el: Node | null = target; while ((el = el.parentNode)) { if (el === current) return true; } return false; } export const isPaternalExposeElements = (root?: HTMLElement | null, target?: HTMLElement | null) => !!root && !!target && (root === document.body || root.dataset?.mlRoot === DomDatasetBoolean.TRUE) && contains(root, target); export const getElementKey = (el?: HTMLElement | null): string => { if (!el) return ''; const attrValue = el.getAttribute('ml-key'); if (attrValue && attrValue.length > 0) { return attrValue; } const dataValue = el.dataset.mlKey; if (dataValue && dataValue.length > 0) { return dataValue; } return ''; };