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:
@@ -14,7 +14,7 @@
|
|||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
||||||
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
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 isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||||
@@ -3137,7 +3137,10 @@ callExpr.push(dictGet(kwargs, k)); } }
|
|||||||
link.addEventListener("click", function(e) {
|
link.addEventListener("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var pathname = urlPathname(href);
|
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) {}
|
try { history.pushState({ sxUrl: href, scrollY: window.scrollY }, "", href); } catch (err) {}
|
||||||
if (typeof window !== "undefined") window.scrollTo(0, 0);
|
if (typeof window !== "undefined") window.scrollTo(0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2616,7 +2616,10 @@ PLATFORM_ORCHESTRATION_JS = """
|
|||||||
link.addEventListener("click", function(e) {
|
link.addEventListener("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var pathname = urlPathname(href);
|
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) {}
|
try { history.pushState({ sxUrl: href, scrollY: window.scrollY }, "", href); } catch (err) {}
|
||||||
if (typeof window !== "undefined") window.scrollTo(0, 0);
|
if (typeof window !== "undefined") window.scrollTo(0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user