diff --git a/src/server/rendering/template.tsx b/src/server/rendering/template.tsx index 05a8a88a..d2b16c04 100644 --- a/src/server/rendering/template.tsx +++ b/src/server/rendering/template.tsx @@ -67,6 +67,7 @@ export function renderOuterDocument( docHead, renderedHtmlTag, docTitle, + docBody, docHeadNodes, headVNodes, } = state; @@ -90,7 +91,10 @@ export function renderOuterDocument( h("link", { rel: "modulepreload", href: src }) ), headVNodes, - h("body", { dangerouslySetInnerHTML: { __html: opts.bodyHtml } }), + h("body", { + ...docBody, + dangerouslySetInnerHTML: { __html: opts.bodyHtml }, + }), ), ); diff --git a/tests/explicit_app_template_test.ts b/tests/explicit_app_template_test.ts index 0d946349..5d1c5130 100644 --- a/tests/explicit_app_template_test.ts +++ b/tests/explicit_app_template_test.ts @@ -66,3 +66,15 @@ Deno.test("don't duplicate ", async () => { }, ); }); + +Deno.test("sets <html> + <head> + <body> classes", async () => { + await withFresh( + "./tests/fixture_explicit_app/main.ts", + async (address) => { + const doc = await fetchHtml(`${address}`); + assertSelector(doc, "html.html"); + assertSelector(doc, "head.head"); + assertSelector(doc, "body.body"); + }, + ); +}); diff --git a/tests/fixture_explicit_app/routes/_app.tsx b/tests/fixture_explicit_app/routes/_app.tsx index 14980273..295434f2 100644 --- a/tests/fixture_explicit_app/routes/_app.tsx +++ b/tests/fixture_explicit_app/routes/_app.tsx @@ -9,13 +9,13 @@ export default function App( { Component, state }: AppProps<unknown, { lang: string }>, ) { return ( - <html lang={state.lang}> - <head> + <html lang={state.lang} class="html"> + <head class="head"> <meta charSet="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>fresh title - +