1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-02-22 18:42:23 +01:00
developer-roadmap/lib/renderer.ts
2022-08-28 03:11:00 +04:00

22 lines
596 B
TypeScript

export function removeSortingInfo(groupId: string) {
return (groupId || '').replace(/^\d+-/, '');
}
export function queryGroupElementsById(groupId: string) {
const elements = document.querySelectorAll(
`[data-group-id$="-${groupId}"]`
) as any;
const matchingElements: HTMLElement[] = [];
elements.forEach((element: HTMLElement) => {
const foundGroupId = element?.dataset?.groupId || '';
const validGroupRegex = new RegExp(`^\\d+-${groupId}$`);
if (validGroupRegex.test(foundGroupId)) {
matchingElements.push(element);
}
});
return matchingElements;
}