web: re-boost swapped content from the [sx-boost] ancestor (fixes back-then-click full reload)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s

After a fragment swap, process-elements(target) -> process-boosted(target) only
boosted [sx-boost] containers that are DESCENDANTS of the swap target. But the
swap target (#content) is nested UNDER the boost wrapper (<div sx-boost="#content">
<div id="content">), so re-boosting scoped to the target found nothing — the
swapped-in links never got bound. Only the initial document-wide boot boost
worked, so: home->sub worked (home links boosted at boot), but Back restored the
home content unboosted, and the next click did a full page reload. (Post-page
links were unboosted too; Back just exposed it.)

process-boosted now ALSO boosts from the nearest [sx-boost] ANCESTOR of root
(dom-closest), so any swap target inside a boost scope gets its links rebound.
is-processed? guards keep it idempotent.

spa-check: the back-button test now clicks AGAIN after Back and asserts it's a
SPA nav (no full reload) — would have caught this. .sxbc regenerated.

Verified: spa-check 4/4 (incl. click-after-back).
This commit is contained in:
2026-06-29 13:41:50 +00:00
parent f5b6612ee1
commit b9a24d5870
4 changed files with 41 additions and 8 deletions

View File

@@ -67,5 +67,14 @@ test.describe('blog SPA', () => {
await page.goBack(); await page.goBack();
await page.waitForURL((u) => u.pathname === '/', { timeout: 15000 }); await page.waitForURL((u) => u.pathname === '/', { timeout: 15000 });
await expect(page.locator('#content h1')).toContainText('Posts'); await expect(page.locator('#content h1')).toContainText('Posts');
// and a click AFTER back must still be a SPA nav, not a full reload — the
// restored content has to be re-boosted (its [sx-boost] marker is an
// ancestor of the swap target, so the re-boost must scan upward).
await page.evaluate(() => { window.__noReload2 = true; });
const link2 = page.locator(POSTLINK).first();
const href2 = await link2.getAttribute('href');
await link2.click();
await page.waitForURL((u) => u.pathname === href2, { timeout: 15000 });
expect(await page.evaluate(() => window.__noReload2)).toBe(true);
}); });
}); });

View File

@@ -714,9 +714,21 @@
:effects (mutation io) :effects (mutation io)
(fn (fn
(root) (root)
(for-each (do
(fn (container) (boost-descendants container)) ;; boost [sx-boost] containers WITHIN root (the document-scan case)
(dom-query-all (or root (dom-body)) "[sx-boost]")))) (for-each
(fn (container) (boost-descendants container))
(dom-query-all (or root (dom-body)) "[sx-boost]"))
;; ALSO boost from the nearest [sx-boost] ANCESTOR of root: a swap
;; target (e.g. #content) is nested under <div sx-boost>, so re-boosting
;; scoped to the target alone never finds the marker, leaving the
;; swapped-in links dead (full reload on the next click). is-processed?
;; guards keep this idempotent.
(when
root
(let
((anc (dom-closest root "[sx-boost]")))
(when anc (boost-descendants anc)))))))
(define (define
boost-descendants boost-descendants
:effects (mutation io) :effects (mutation io)

File diff suppressed because one or more lines are too long

View File

@@ -714,9 +714,21 @@
:effects (mutation io) :effects (mutation io)
(fn (fn
(root) (root)
(for-each (do
(fn (container) (boost-descendants container)) ;; boost [sx-boost] containers WITHIN root (the document-scan case)
(dom-query-all (or root (dom-body)) "[sx-boost]")))) (for-each
(fn (container) (boost-descendants container))
(dom-query-all (or root (dom-body)) "[sx-boost]"))
;; ALSO boost from the nearest [sx-boost] ANCESTOR of root: a swap
;; target (e.g. #content) is nested under <div sx-boost>, so re-boosting
;; scoped to the target alone never finds the marker, leaving the
;; swapped-in links dead (full reload on the next click). is-processed?
;; guards keep this idempotent.
(when
root
(let
((anc (dom-closest root "[sx-boost]")))
(when anc (boost-descendants anc)))))))
(define (define
boost-descendants boost-descendants
:effects (mutation io) :effects (mutation io)