Skip to content

Commit a026010

Browse files
committed
fix(core): filter DSD template from client-navigation swap + update rubric
Client router: when swapping the layout shell's light-DOM children on navigation, the new body from DOMParser contains a <template shadowrootmode="open"> element (the SSR's Declarative Shadow DOM). DOMParser doesn't process DSD, so it stays as a regular DOM element. Inserting it as light DOM into a shell that already has a shadow root caused a brief layout flash — the template element disrupted slot projection for one frame. Fix: filter out any <template> with a shadowrootmode attribute before calling replaceChildren. The shadow root already exists from the initial page load; the DSD template is stale and shouldn't be in the light DOM. Also: landing page rubric changed from "ai-first · open source framework" to "webjs: ai-first framework" per user request.
1 parent c178975 commit a026010

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

docs/app/page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export default function LandingPage() {
181181
</style>
182182
183183
<section class="hero">
184-
<div class="rubric">● ai-first · open source framework</div>
184+
<div class="rubric">webjs: ai-first framework</div>
185185
<h1>The framework AI agents can read, write, and ship.</h1>
186186
<p>
187187
webjs is an AI-first, no-build, web-components-first framework inspired by Next.js.

packages/core/src/router-client.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,14 @@ function swapBody(newBody) {
202202
) {
203203
// Same layout shell — swap only the light-DOM children (page content).
204204
// Keep the shell element itself (and its shadow root with chrome).
205-
const children = [...newShell.childNodes];
205+
//
206+
// Filter out <template shadowrootmode="open"> — that's the Declarative
207+
// Shadow DOM from SSR. On client navigation the shadow root already
208+
// exists; inserting the DSD template as light DOM would add a stale
209+
// invisible element that can confuse slot projection and cause a flash.
210+
const children = [...newShell.childNodes].filter(
211+
(n) => !(n instanceof HTMLTemplateElement && /** @type any */ (n).getAttribute('shadowrootmode'))
212+
);
206213
currentShell.replaceChildren(...children);
207214
} else {
208215
// Different structure — full swap.

0 commit comments

Comments
 (0)