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 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 00:46:25 +00:00
parent 9278be9fe2
commit ac1dc34dad
2 changed files with 9 additions and 3 deletions

View File

@@ -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 {