Re-read element attributes at click time, not from closed-over bind values
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m39s

All click handlers (bind-event, bindBoostLink, bindClientRouteClick)
now re-read href/verb-info from the DOM element when the click fires,
instead of using values captured at bind time. This ensures correct
behavior when DOM is replaced or attributes are morphed after binding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 02:06:21 +00:00
parent 09d06a4c87
commit b85a46bb62
3 changed files with 38 additions and 30 deletions

View File

@@ -388,33 +388,33 @@
(dom-has-attr? el "href")))
(prevent-default e))
;; For GET clicks on links, try client-side routing first
(let ((is-get-link (and (= event-name "click")
(= (get verbInfo "method") "GET")
;; Re-read verb info from element at click time (not closed-over)
(let ((live-info (or (get-verb-info el) verbInfo))
(is-get-link (and (= event-name "click")
(= (get live-info "method") "GET")
(dom-has-attr? el "href")
(not (get mods "delay"))))
(client-routed false))
(when is-get-link
(log-info (str "sx:route trying " (get verbInfo "url")))
(set! client-routed
(try-client-route
(url-pathname (get verbInfo "url"))
(url-pathname (get live-info "url"))
(dom-get-attr el "sx-target"))))
(if client-routed
(do
(browser-push-state (get verbInfo "url"))
(browser-push-state (get live-info "url"))
(browser-scroll-to 0 0))
(do
(when is-get-link
(log-info (str "sx:route server fetch " (get verbInfo "url"))))
(log-info (str "sx:route server fetch " (get live-info "url"))))
(if (get mods "delay")
(do
(clear-timeout timer)
(set! timer
(set-timeout
(fn () (execute-request el verbInfo nil))
(fn () (execute-request el nil nil))
(get mods "delay"))))
(execute-request el verbInfo nil))))))))
(execute-request el nil nil))))))))
(if (get mods "once") (dict "once" true) nil))))))