@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
38 lines (37 loc) • 1.24 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
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, '\\$&');
};
export 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);
};
export const attachInternals = (host) => {
const attach = host.attachInternals;
if (!attach)
return undefined;
try {
const internals = attach.call(host);
return internals;
}
catch (_a) {
return undefined;
}
};
//# sourceMappingURL=aria-labelledby.js.map