@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
57 lines (53 loc) • 1.91 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { b as watchValidator, L as Log } from './common-Cx_AGO_M.js';
const escapeCssIdentifier = (value) => {
var _a;
if ((_a = globalThis.CSS) === null || _a === void 0 ? void 0 : _a.escape) {
return globalThis.CSS.escape(value);
}
return value.replace(/[^a-zA-Z0-9_-]/g, '\\$&');
};
const resolveTargets = (host, value) => {
const ids = (value !== null && value !== void 0 ? value : '').trim().split(/\s+/).filter(Boolean);
if (!ids.length)
return [];
const root = host === null || host === void 0 ? void 0 : host.getRootNode();
const getById = (id) => {
if (root instanceof Document)
return root.getElementById(id);
if (root instanceof ShadowRoot)
return root.querySelector(`#${escapeCssIdentifier(id)}`);
return typeof document !== 'undefined' ? document.getElementById(id) : null;
};
return ids.map(getById).filter((el) => !!el);
};
const attachInternals = (host) => {
const attach = host.attachInternals;
if (!attach)
return undefined;
try {
const internals = attach.call(host);
return internals;
}
catch (_a) {
return undefined;
}
};
const validateAriaLabelledby = (component, host, internals, value) => {
watchValidator(component, '_ariaLabelledby', (value) => typeof value === 'string' || typeof value === 'undefined', new Set(['string']), value);
const elements = resolveTargets(host, value);
if (internals) {
try {
internals.ariaLabelledByElements = elements;
}
catch (_a) {
}
Log.debug(['WebComponent internals', internals]);
}
return elements;
};
export { attachInternals as a, validateAriaLabelledby as v };
//# sourceMappingURL=aria-labelledby-CEzR68x-.js.map
//# sourceMappingURL=aria-labelledby-CEzR68x-.js.map