From ac1dc34dad71efb67790fd8ebd14bcb4791eea17 Mon Sep 17 00:00:00 2001 From: giles Date: Sat, 7 Mar 2026 00:46:25 +0000 Subject: [PATCH] Fix: pass target selector to tryClientRoute from link clicks bindClientRouteClick was calling tryClientRoute(pathname) without the target-sel argument. This caused resolve-route-target to return nil, so client routing ALWAYS fell back to server fetch on link clicks. Now finds the sx-boost ancestor and passes its target selector. Co-Authored-By: Claude Opus 4.6 --- shared/static/scripts/sx-browser.js | 7 +++++-- shared/sx/ref/bootstrap_js.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/shared/static/scripts/sx-browser.js b/shared/static/scripts/sx-browser.js index 64b8fcd..fbd46a2 100644 --- a/shared/static/scripts/sx-browser.js +++ b/shared/static/scripts/sx-browser.js @@ -14,7 +14,7 @@ // ========================================================================= var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } }); - var SX_VERSION = "2026-03-07T00:33:33Z"; + var SX_VERSION = "2026-03-07T00:46:09Z"; function isNil(x) { return x === NIL || x === null || x === undefined; } function isSxTruthy(x) { return x !== false && !isNil(x); } @@ -3137,7 +3137,10 @@ callExpr.push(dictGet(kwargs, k)); } } link.addEventListener("click", function(e) { e.preventDefault(); var pathname = urlPathname(href); - if (tryClientRoute(pathname)) { + // Find the sx-boost target selector from the link's ancestor + var boostEl = link.closest("[sx-boost]"); + var targetSel = boostEl ? boostEl.getAttribute("sx-boost") : null; + if (tryClientRoute(pathname, targetSel)) { try { history.pushState({ sxUrl: href, scrollY: window.scrollY }, "", href); } catch (err) {} if (typeof window !== "undefined") window.scrollTo(0, 0); } else { diff --git a/shared/sx/ref/bootstrap_js.py b/shared/sx/ref/bootstrap_js.py index d87bc97..4d9595a 100644 --- a/shared/sx/ref/bootstrap_js.py +++ b/shared/sx/ref/bootstrap_js.py @@ -2616,7 +2616,10 @@ PLATFORM_ORCHESTRATION_JS = """ link.addEventListener("click", function(e) { e.preventDefault(); var pathname = urlPathname(href); - if (tryClientRoute(pathname)) { + // Find the sx-boost target selector from the link's ancestor + var boostEl = link.closest("[sx-boost]"); + var targetSel = boostEl ? boostEl.getAttribute("sx-boost") : null; + if (tryClientRoute(pathname, targetSel)) { try { history.pushState({ sxUrl: href, scrollY: window.scrollY }, "", href); } catch (err) {} if (typeof window !== "undefined") window.scrollTo(0, 0); } else {