stx-router 0.2.248 → 0.2.250

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 +16 -1
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -1329,6 +1329,21 @@ else {
1329
1329
  // mode where every page is part of the same SPA shell.
1330
1330
  document.addEventListener('click',function(e){
1331
1331
  if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;
1332
+ // A handler on the page has already decided this click is not a
1333
+ // navigation, so the router must not perform one - the same contract the
1334
+ // browser honours for a plain anchor.
1335
+ //
1336
+ // This listener used to run in the CAPTURE phase, which broke that twice
1337
+ // over: it saw the click before the anchor did, so defaultPrevented was
1338
+ // necessarily false by the time it was read here, and the stopPropagation
1339
+ // below then stopped the event ever reaching the element - so a page's own
1340
+ // click handler on an intercepted link never ran AT ALL. Progressive
1341
+ // enhancement on an anchor was impossible; the only way out was to swap it
1342
+ // for a button in script (stacksjs/stacks#2393).
1343
+ //
1344
+ // Bubbling instead puts the page's handlers first, which is where a
1345
+ // decision about the page's own markup belongs.
1346
+ if(e.defaultPrevented)return;
1332
1347
  if(!e.target||!e.target.closest)return;
1333
1348
  var link=e.target.closest('[data-stx-link]');
1334
1349
  // A marked link still has to clear the opt-out set. It used to skip it
@@ -1346,7 +1361,7 @@ else {
1346
1361
  e.stopPropagation();
1347
1362
  log('[router] navigating to:',href);
1348
1363
  navigate(withCurrentLocale(href));
1349
- },true);
1364
+ });
1350
1365
 
1351
1366
  // \u2500\u2500 Form submission \u2500\u2500
1352
1367
  // A submit IS a navigation, and the router only ever watched clicks. So any
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stx-router",
3
3
  "type": "module",
4
- "version": "0.2.248",
4
+ "version": "0.2.250",
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",