Skip to content

Commit f7983ad

Browse files
authored
Always prepend DOCTYPE in SPA mode entry.server.tsx (#8725)
1 parent 30544ed commit f7983ad

File tree

2 files changed

+4
-48
lines changed

2 files changed

+4
-48
lines changed

integration/spa-mode-test.ts

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ test.describe("SPA Mode", () => {
176176
});
177177
});
178178

179-
test("prepends DOCTYPE to <html> documents if not present", async () => {
179+
test("prepends DOCTYPE to HTML in the default entry.server.tsx", async () => {
180180
let fixture = await createFixture({
181181
compiler: "vite",
182182
spaMode: true,
@@ -222,48 +222,6 @@ test.describe("SPA Mode", () => {
222222
expect(await res.text()).toMatch(/^<!DOCTYPE html>\n<html lang="en">/);
223223
});
224224

225-
test("does not prepend DOCTYPE if user is not hydrating the document", async () => {
226-
let fixture = await createFixture({
227-
compiler: "vite",
228-
spaMode: true,
229-
files: {
230-
"vite.config.ts": js`
231-
import { defineConfig } from "vite";
232-
import { vitePlugin as remix } from "@remix-run/dev";
233-
234-
export default defineConfig({
235-
plugins: [remix({ ssr: false })],
236-
});
237-
`,
238-
"app/root.tsx": js`
239-
import { Outlet, Scripts } from "@remix-run/react";
240-
241-
export default function Root() {
242-
return (
243-
<div>
244-
<h1 data-root>Root</h1>
245-
<Scripts />
246-
</div>
247-
);
248-
}
249-
250-
export function HydrateFallback() {
251-
return (
252-
<div>
253-
<h1>Loading SPA...</h1>
254-
<Scripts />
255-
</div>
256-
);
257-
}
258-
`,
259-
},
260-
});
261-
let res = await fixture.requestDocument("/");
262-
let html = await res.text();
263-
expect(html).toMatch(/^<div>/);
264-
expect(html).not.toMatch(/<!DOCTYPE html>/);
265-
});
266-
267225
test("works when combined with a basename", async ({ page }) => {
268226
fixture = await createFixture({
269227
compiler: "vite",
@@ -363,7 +321,7 @@ test.describe("SPA Mode", () => {
363321
<title>Not from Remix!</title>
364322
</head>
365323
<body>
366-
<div id="app"><!-- Remix-SPA--></div>
324+
<div id="app"><!-- Remix SPA --></div>
367325
</body>
368326
</html>
369327
`,
@@ -406,7 +364,7 @@ test.describe("SPA Mode", () => {
406364
);
407365
408366
const html = shellHtml.replace(
409-
"<!-- Remix-SPA-->",
367+
"<!-- Remix SPA -->",
410368
appHtml
411369
);
412370

packages/remix-dev/config/defaults/entry.server.spa.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export default function handleRequest(
1212
let html = renderToString(
1313
<RemixServer context={remixContext} url={request.url} />
1414
);
15-
if (html.startsWith("<html")) {
16-
html = "<!DOCTYPE html>\n" + html;
17-
}
15+
html = "<!DOCTYPE html>\n" + html;
1816
return new Response(html, {
1917
headers: { "Content-Type": "text/html" },
2018
status: responseStatusCode,

0 commit comments

Comments
 (0)