stx-router 0.2.346 → 0.2.347

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 +27 -3
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -2125,9 +2125,24 @@ else {
2125
2125
  // point at this path, exactly one is.
2126
2126
  var have=new URLSearchParams(location.search),q=true;
2127
2127
  u.searchParams.forEach(function(v,k){if(have.getAll(k).indexOf(v)===-1)q=false});
2128
+ // EXACT is the stricter half (stacksjs/stx#2017). A link with NO query
2129
+ // satisfied the loop above trivially, so a bare /list reported itself exact
2130
+ // on /list?status=up - taking exact-active-class and aria-current from the
2131
+ // chip the user was actually on, and telling a screen reader the unfiltered
2132
+ // link was the current page.
2133
+ //
2134
+ // Only a link with no query at all is held to the stricter test, which is
2135
+ // what keeps #1777 working: a range picker's /dashboard?site=1&range=7d is
2136
+ // still exact on /dashboard?site=1&range=7d&country=US, because a page
2137
+ // filter the link does not name should not unmark the range it IS on. The
2138
+ // two requests look opposed and are not - one is about a link naming MORE
2139
+ // than the page, the other about a link naming NOTHING.
2140
+ var linkHasQuery=false;
2141
+ u.searchParams.forEach(function(){linkHasQuery=true});
2142
+ var sameQuery=q&&(linkHasQuery||!location.search);
2128
2143
  var matched=matchesAny(also,cur);
2129
2144
  return {
2130
- exact:q&&path===cur,
2145
+ exact:sameQuery&&path===cur,
2131
2146
  active:q&&(path==='/'?cur==='/':(cur===path||cur.indexOf(path+'/')===0))||matched,
2132
2147
  matched:matched
2133
2148
  };
@@ -2179,12 +2194,21 @@ else {
2179
2194
  // Only ever touched on links that already carry the attribute or are the
2180
2195
  // current one, so a page using aria-current for something else \u2014 a step in a
2181
2196
  // wizard, a sort direction \u2014 is not rewritten out from under itself.
2197
+ //
2198
+ // Cleared for 'true' as well as 'page' (#2017). Both say "this is the current
2199
+ // one" with no further meaning, and a consumer working around a missing
2200
+ // aria-current by stamping aria-current="true" server-side kept it forever:
2201
+ // the router neither updated nor removed it, so after one navigation it named
2202
+ // the wrong link and the workaround was worse than the bug. The role-specific
2203
+ // values - step, location, date, time - are still left alone, because those
2204
+ // ARE the page using the attribute for something else.
2182
2205
  function markCurrent(link,isExact){
2206
+ var now=link.getAttribute('aria-current');
2183
2207
  if(isExact){
2184
- if(link.getAttribute('aria-current')!=='page')link.setAttribute('aria-current','page');
2208
+ if(now!=='page')link.setAttribute('aria-current','page');
2185
2209
  return;
2186
2210
  }
2187
- if(link.getAttribute('aria-current')==='page')link.removeAttribute('aria-current');
2211
+ if(now==='page'||now==='true')link.removeAttribute('aria-current');
2188
2212
  }
2189
2213
 
2190
2214
  // \u2500\u2500 Progress bar DOM + style \u2500\u2500
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stx-router",
3
3
  "type": "module",
4
- "version": "0.2.346",
4
+ "version": "0.2.347",
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",