web: morph preserves the boost's injected sx-* attrs — fix edit-page swap clobbering #content

Reported: logged in, go to an edit page, then press Home — nothing happens.

Root cause (browser-DOM trace): a boosted nav home→post morphs a home footer <a> into the
post's "edit" link (morph reuses nodes positionally). morph-node's sync-attrs then STRIPS any
attribute the old node has but the SERVER node lacks — which removes the boost's
client-injected sx-swap="innerHTML" (the server never sends it). With sx-swap gone the swap
defaults to outerHTML, so clicking edit REPLACES #content (the <div id=content>) with the edit
fragment's <div> (no id) — DOM trace: "sx-boost children [NAV, DIV#content]" → "[NAV, DIV]".
#content is destroyed, so every later boosted nav (Home) fetches but has no swap target
("post-swap: root=nil") → nothing updates.

Fix: sync-attrs no longer removes the boost's injected navigation attributes (sx-target /
sx-swap / sx-push-url / sx-get / sx-select) when the new (server) node lacks them — they're
identical across all boosted links, so a reused node keeps sx-swap="innerHTML" and the swap
morphs #content's children instead of replacing #content. Recompiled the web stack. Pairs
with a511b21d (fresh href) + 88f8b427 (SX-Redirect) — three facets of the morph-node-reuse
problem (stale href, lost swap attr, guarded-redirect clobber).

TEST-FIRST: added a 3rd boost-nav.spec.js case (LOGGED IN: home→post→edit, assert #content
survives + Home works). Reproduced RED via DOM traces (#content count 0), GREEN after — on the
ephemeral server AND live. No regressions: picker 3/3 + block-editor 1/1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 07:17:59 +00:00
parent 88f8b427c5
commit 7bec86289c
5 changed files with 61 additions and 5 deletions

View File

@@ -468,7 +468,19 @@
(and
(not (dom-has-attr? new-el aname))
(not (contains? reactive-attrs aname))
(not (= aname "data-sx-reactive-attrs")))
(not (= aname "data-sx-reactive-attrs"))
;; PRESERVE the boost's client-injected navigation attributes. The boost
;; (boost-descendants) sets sx-target/sx-swap/sx-push-url on links; the
;; SERVER never sends them, so this removal loop would strip them when a
;; morph reuses a node for a different link — leaving sx-swap unset, which
;; defaults to outerHTML and REPLACES the swap target (#content), breaking
;; every later nav. These are identical across all boosted links, so
;; keeping them on a reused node is correct.
(not (= aname "sx-target"))
(not (= aname "sx-swap"))
(not (= aname "sx-push-url"))
(not (= aname "sx-get"))
(not (= aname "sx-select")))
(dom-remove-attr old-el aname))))
(dom-attr-list old-el)))))
(define

File diff suppressed because one or more lines are too long