Add explicit logging for route decisions in bind-event
- Log "sx:route server fetch <url>" when falling back to network - Use console.error for eval errors (not console.warn) - Restructure bind-event to separate client route check from &&-chain Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2630,7 +2630,7 @@ PLATFORM_ORCHESTRATION_JS = """
|
||||
}
|
||||
return sxRenderWithEnv(source, merged);
|
||||
} catch (e) {
|
||||
console.warn("sx:route eval error", e);
|
||||
console.error("[sx-ref] sx:route eval error for:", source, e);
|
||||
return NIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,24 +389,29 @@
|
||||
(prevent-default e))
|
||||
|
||||
;; For GET clicks on links, try client-side routing first
|
||||
(if (and (= event-name "click")
|
||||
(= (get verbInfo "method") "GET")
|
||||
(dom-has-attr? el "href")
|
||||
(not (get mods "delay"))
|
||||
(try-client-route (url-pathname (get verbInfo "url"))))
|
||||
;; Client route succeeded — push state, scroll to top
|
||||
(do
|
||||
(browser-push-state (get verbInfo "url"))
|
||||
(browser-scroll-to 0 0))
|
||||
;; Fall through to server fetch
|
||||
(if (get mods "delay")
|
||||
(let ((is-get-link (and (= event-name "click")
|
||||
(= (get verbInfo "method") "GET")
|
||||
(dom-has-attr? el "href")
|
||||
(not (get mods "delay"))))
|
||||
(client-routed false))
|
||||
(when is-get-link
|
||||
(set! client-routed
|
||||
(try-client-route (url-pathname (get verbInfo "url")))))
|
||||
(if client-routed
|
||||
(do
|
||||
(clear-timeout timer)
|
||||
(set! timer
|
||||
(set-timeout
|
||||
(fn () (execute-request el verbInfo nil))
|
||||
(get mods "delay"))))
|
||||
(execute-request el verbInfo nil))))))
|
||||
(browser-push-state (get verbInfo "url"))
|
||||
(browser-scroll-to 0 0))
|
||||
(do
|
||||
(when is-get-link
|
||||
(log-info (str "sx:route server fetch " (get verbInfo "url"))))
|
||||
(if (get mods "delay")
|
||||
(do
|
||||
(clear-timeout timer)
|
||||
(set! timer
|
||||
(set-timeout
|
||||
(fn () (execute-request el verbInfo nil))
|
||||
(get mods "delay"))))
|
||||
(execute-request el verbInfo nil))))))))
|
||||
(if (get mods "once") (dict "once" true) nil))))))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user