stx-router 0.2.220 → 0.2.222

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.
Files changed (2) hide show
  1. package/dist/client.js +19 -0
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -1549,9 +1549,28 @@ else {
1549
1549
  var isActive=href!=='/'?cur.startsWith(href):cur==='/';
1550
1550
  if(isExact)eac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
1551
1551
  if(isActive)ac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
1552
+ markCurrent(link,isExact);
1552
1553
  });
1553
1554
  }
1554
1555
 
1556
+ // aria-current="page" names the page the user is ON, so it has to move when
1557
+ // the page does. The server stamps it on the link for the page it rendered;
1558
+ // after that, only a full load would ever correct it, and a fragment swap is
1559
+ // not a full load. Left alone, a screen reader announces the entry the user
1560
+ // arrived through as current for the rest of the session, however far they
1561
+ // navigate \u2014 silently wrong, and only to the people relying on it.
1562
+ //
1563
+ // Only ever touched on links that already carry the attribute or are the
1564
+ // current one, so a page using aria-current for something else \u2014 a step in a
1565
+ // wizard, a sort direction \u2014 is not rewritten out from under itself.
1566
+ function markCurrent(link,isExact){
1567
+ if(isExact){
1568
+ if(link.getAttribute('aria-current')!=='page')link.setAttribute('aria-current','page');
1569
+ return;
1570
+ }
1571
+ if(link.getAttribute('aria-current')==='page')link.removeAttribute('aria-current');
1572
+ }
1573
+
1555
1574
  // \u2500\u2500 Progress bar DOM + style \u2500\u2500
1556
1575
  // Injects a fixed-position element at the top of the viewport plus the
1557
1576
  // minimal CSS for its transform/opacity transitions. Kept idempotent so
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stx-router",
3
3
  "type": "module",
4
- "version": "0.2.220",
4
+ "version": "0.2.222",
5
5
  "description": "File-based router for STX — .stx template discovery, nested layouts, typed route params, middleware, and client-side SPA navigation.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",