fix: attributes on <body> not being rendered (#1648)

This commit is contained in:
Marvin Hagemeister
2023-08-16 22:26:23 +02:00
committed by GitHub
parent 09dc65604b
commit 9f97e3423c
3 changed files with 20 additions and 4 deletions
+5 -1
View File
@@ -67,6 +67,7 @@ export function renderOuterDocument(
docHead, docHead,
renderedHtmlTag, renderedHtmlTag,
docTitle, docTitle,
docBody,
docHeadNodes, docHeadNodes,
headVNodes, headVNodes,
} = state; } = state;
@@ -90,7 +91,10 @@ export function renderOuterDocument(
h("link", { rel: "modulepreload", href: src }) h("link", { rel: "modulepreload", href: src })
), ),
headVNodes, headVNodes,
h("body", { dangerouslySetInnerHTML: { __html: opts.bodyHtml } }), h("body", {
...docBody,
dangerouslySetInnerHTML: { __html: opts.bodyHtml },
}),
), ),
); );
+12
View File
@@ -66,3 +66,15 @@ Deno.test("don't duplicate <title>", 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");
},
);
});
+3 -3
View File
@@ -9,13 +9,13 @@ export default function App(
{ Component, state }: AppProps<unknown, { lang: string }>, { Component, state }: AppProps<unknown, { lang: string }>,
) { ) {
return ( return (
<html lang={state.lang}> <html lang={state.lang} class="html">
<head> <head class="head">
<meta charSet="utf-8" /> <meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>fresh title</title> <title>fresh title</title>
</head> </head>
<body> <body class="body">
<div class="inner-body"> <div class="inner-body">
<Component /> <Component />
</div> </div>