From 4b1518f1bc9999d72121e2284bc217f0e62df943 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 6 Dec 2026 11:41:58 +0000 Subject: [PATCH 1/3] Swaps: another origin's module scripts do not decide the swap; a fallback load still morphs The swap imported every module script of the next page and loaded the page instead if any failed. A CDN's injected analytics beacon (Cloudflare's, on realworld.tiaforge.dev) blocked by an extension or offline turned every swap into a load. Only the page's own-origin modules are imported and awaited now; another origin's run after the commit through script elements, once per document, so their `integrity` and `crossorigin` apply (an `import()` ignored the integrity). A swap that loads instead navigated with `location.assign()`, whose navigation carries no link: the page's `pageswap` found no row and nothing morphed. It now navigates with the link in `info`, as `navigate()` calls do, here and where a history write makes the swap navigate again. e2e/permanent: a beacon on another origin that does not load, whose integrity does not match, and that runs once per document; and a swap that loads instead still morphing its pair. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AjKzdzTBYrLUCJWpL1Vstr --- CHANGELOG.md | 7 ++++ docs/navigation.md | 6 ++- e2e/permanent/README.md | 5 ++- e2e/permanent/run.mjs | 83 +++++++++++++++++++++++++++++++++++++++-- src/links.ts | 4 +- src/swap-run.ts | 19 +++++++++- src/swap.ts | 14 +++++-- 7 files changed, 127 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc5053b..9b7828c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,13 @@ How to write an entry (from 0.21.0 on; older sections keep their own form): family with a fitted fallback now gets its own fitted face, deferred or not, in whichever of the build's stylesheets it is ([fonts after the load](docs/first-paint.md#fonts-after-the-load)). +- A swap no longer fails because of another origin's module script on the next page (an analytics beacon a CDN + injects, such as Cloudflare's, blocked by an extension or offline): only the app's own modules decide the swap; the + others run after it, once per document, as on a load, with their `integrity` checked, which the swap's `import()` + skipped before ([swaps](docs/navigation.md#swaps)). +- A swap that loads its page instead (the page answered an error, a module failed to load) still morphs its + `data-sn-transition` pair: the load is handed the link that started it + ([page transitions](docs/navigation.md#page-transitions)). ## 0.23.1 (2026-12-02) diff --git a/docs/navigation.md b/docs/navigation.md index 686843e7..eb110d0a 100644 --- a/docs/navigation.md +++ b/docs/navigation.md @@ -322,6 +322,9 @@ link's `#hash` is scrolled to, and the new title is announced to screen readers. page's body (`SN540`). App modules run once per document: per-page work goes in a listener for `sn-page`, which `document` gets after each page mounts, the first one included (`e.detail.kind` is `load`, `push`, `replace` or `traverse`). +- Another origin's module scripts on the next page (an analytics beacon your CDN injects) run after the swap, + once per document, with their `integrity` checked, as on a load. The swap does not wait for them, and one that + does not load (blocked by an extension) does not stop it: only the app's own modules do. - Every page runs under the first page's response headers, its Content-Security-Policy included: one policy for the app. With a nonce policy, put each response's nonce in `` too: the swap trusts what the server gave the next page's nonce (its styles, its module @@ -401,7 +404,8 @@ element it becomes on the detail page: list needs nothing: its rows come back as it was left ([Back and Forward](resources.md#back-and-forward)). A link to a list (not Back) morphs into it only with `cache` on its resource, or its rows arrive too late and it only fades. -- One morph per navigation. Navigations sinter starts itself (a redirect) do not morph. +- One morph per navigation. Navigations sinter starts itself (a redirect) do not morph, except a swap + that loads its page instead: that load still morphs from the link's row. - **Reduced motion:** when the visitor's system asks for reduced motion (`prefers-reduced-motion: reduce`), nothing morphs. The fade is your CSS: temper's rule turns it off then too; without temper, put your `@view-transition` rule inside `@media (prefers-reduced-motion: no-preference) { … }`. diff --git a/e2e/permanent/README.md b/e2e/permanent/README.md index e9cfd4e6..08b6bc1c 100644 --- a/e2e/permanent/README.md +++ b/e2e/permanent/README.md @@ -17,7 +17,10 @@ each swap; the new title announced; `