diff --git a/bun.lock b/bun.lock index 40981e57..39fcddb8 100644 --- a/bun.lock +++ b/bun.lock @@ -375,7 +375,7 @@ }, "packages/csr": { "name": "@wrnexus/csr", - "version": "0.8.43", + "version": "0.8.44", "dependencies": { "@wrnexus/core": "workspace:*", }, diff --git a/packages/csr/package.json b/packages/csr/package.json index 4d455bb2..1e6726a9 100644 --- a/packages/csr/package.json +++ b/packages/csr/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/csr", - "version": "0.8.43", + "version": "0.8.44", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/csr/src/nav-runtime.ts b/packages/csr/src/nav-runtime.ts index f43e5436..4efe7ae1 100644 --- a/packages/csr/src/nav-runtime.ts +++ b/packages/csr/src/nav-runtime.ts @@ -576,7 +576,10 @@ export const NAV_RUNTIME = String.raw` document.querySelectorAll('script[data-wrn-controls]').forEach(function (node) { node.remove(); }); doc.querySelectorAll('script[data-wrn-controls]').forEach(function (node) { - document.body.appendChild(document.importNode(node, true)); + // Preserve parser-created inert JSON nodes. Deep cloning script text + // makes Chrome recheck it as a modified script under Trusted Types. + if (node.getAttribute("type") !== "application/json") return; + document.body.appendChild(document.adoptNode(node)); }); var importedNodes = []; diff --git a/packages/csr/test/nav.test.ts b/packages/csr/test/nav.test.ts index d3a940ac..9ea49b1b 100644 --- a/packages/csr/test/nav.test.ts +++ b/packages/csr/test/nav.test.ts @@ -106,11 +106,18 @@ test("navigation supplies TrustedHTML to the document parser", async () => { test("navigation replaces document control registries before hydration", async () => { install('
'); - nextHtml = '