UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

24 lines (23 loc) 834 B
export function resolveContainerElement(container, context, doc = globalThis.document) { if (container == null) { return null; } const value = typeof container === 'function' ? container(context) : container; if (value == null) { return null; } if (value instanceof HTMLElement) { return value; } if (typeof value === 'object' && 'selector' in value) { const matches = doc.querySelectorAll(value.selector); if (matches.length > 1) { console.warn(`[AdapTable] CSS selector "${value.selector}" matched ${matches.length} elements. Using the first match. Consider using a more specific selector.`); } return matches[0] ?? null; } if (typeof value === 'string') { return doc.getElementById(value); } return null; }