(sidebar, route, locale)
| 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); |
no test coverage detected