MCPcopy Index your code
hub / github.com/crisxuan/bestJavaer / syncSidebarActiveState

Function syncSidebarActiveState

assets/article-cards.js:329–352  ·  view source on GitHub ↗
(sidebar, route, locale)

Source from the content-addressed store, hash-verified

327 }
328
329 function syncSidebarActiveState(sidebar, route, locale) {
330 var activeHref = getActiveSidebarHref(route, locale);
331
332 Array.from(sidebar.querySelectorAll('li.active')).forEach(function (item) {
333 item.classList.remove('active');
334 });
335
336 if (!activeHref) {
337 return;
338 }
339
340 Array.from(sidebar.querySelectorAll('a[href]')).forEach(function (link) {
341 if (normalizeHashHref(link.getAttribute('href') || '') !== activeHref) {
342 return;
343 }
344
345 var item = link.closest('li');
346
347 while (item && sidebar.contains(item)) {
348 item.classList.add('active');
349 item = item.parentElement ? item.parentElement.closest('li') : null;
350 }
351 });
352 }
353
354 function getActiveSidebarHref(route, locale) {
355 var normalizedRoute = normalizeRoute(route);

Callers 1

localizeSidebarFunction · 0.85

Calls 2

getActiveSidebarHrefFunction · 0.85
normalizeHashHrefFunction · 0.85

Tested by

no test coverage detected