@majeanson/lac 3.4.3 → 3.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -21381,13 +21381,25 @@ function showPage(id) {
21381
21381
  }
21382
21382
  // init
21383
21383
  document.querySelectorAll('.feature-page').forEach(p => p.classList.add('hidden'));
21384
- // Hash routing: navigate to feature on load if hash is present
21384
+ // Navigate to feature on page load if hash is present
21385
21385
  (function() {
21386
21386
  var hash = window.location.hash.slice(1);
21387
21387
  if (hash) { showPage(hash); }
21388
21388
  })();
21389
- // Hash routing: respond to browser back/forward navigation
21390
- window.addEventListener('hashchange', function() {
21389
+ // Click delegation catch clicks on any element with data-id (nav items, TOC cards, search results)
21390
+ document.addEventListener('click', function(e) {
21391
+ var el = e.target.closest('[data-id]');
21392
+ if (!el) return;
21393
+ var id = el.dataset.id;
21394
+ if (!id) return;
21395
+ e.preventDefault();
21396
+ showPage(id);
21397
+ history.pushState(null, '', '#' + id);
21398
+ gsearch.value = '';
21399
+ sresults.classList.remove('visible');
21400
+ });
21401
+ // Browser back/forward navigation
21402
+ window.addEventListener('popstate', function() {
21391
21403
  var hash = window.location.hash.slice(1);
21392
21404
  showPage(hash || 'home');
21393
21405
  });
@@ -21417,8 +21429,7 @@ gsearch.addEventListener('input', () => {
21417
21429
  } else {
21418
21430
  sresults.innerHTML = matches.map(f => {
21419
21431
  const snip = strip(f.guide).slice(0, 90) + (f.guide.length > 90 ? '\u2026' : '');
21420
- const id = JSON.stringify(f.id);
21421
- return '<div class="sr-item" onclick="showPage(' + id + ');gsearch.value=\'\';sresults.classList.remove(\'visible\')">'
21432
+ return '<div class="sr-item" data-id="' + f.id + '">'
21422
21433
  + '<div class="sr-title">' + hlText(f.title, q) + '</div>'
21423
21434
  + '<div class="sr-domain">' + hlText(f.domain.replace(/-/g,' '), q) + ' \u00b7 ' + f.status + '</div>'
21424
21435
  + '<div class="sr-snippet">' + hlText(snip, q) + '</div>'