feat: add safe project upgrades and production performance fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/ssr",
|
||||
"version": "0.2.13",
|
||||
"version": "0.2.14",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -55,8 +55,12 @@ export function renderDocument(opts: RenderOptions): string {
|
||||
const extraHead = opts.extraHead ? `\n ${opts.extraHead}` : "";
|
||||
const extraBody = opts.extraBody ? `\n ${opts.extraBody}` : "";
|
||||
|
||||
const htmlAttrs = /(?:^|\s)lang\s*=/.test(opts.htmlAttrs ?? "")
|
||||
? (opts.htmlAttrs ?? "")
|
||||
: `${opts.htmlAttrs ?? ""} lang="en"`;
|
||||
|
||||
return `<!doctype html>
|
||||
<html${opts.htmlAttrs ?? ""}>
|
||||
<html${htmlAttrs}>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
@@ -22,3 +22,16 @@ test("deduplicates runtime scripts and module preloads", () => {
|
||||
expect(html.match(/rel="modulepreload"/g)).toHaveLength(1);
|
||||
expect(html.match(/src="\/app\.js"/g)).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("always emits a document language and preserves an explicit language", () => {
|
||||
const fallback = renderDocument({ meta: {}, body: "" });
|
||||
expect(fallback).toContain('<html lang="en">');
|
||||
|
||||
const explicit = renderDocument({
|
||||
meta: {},
|
||||
body: "",
|
||||
htmlAttrs: ' data-theme="dark" lang="fr"',
|
||||
});
|
||||
expect(explicit).toContain('<html data-theme="dark" lang="fr">');
|
||||
expect(explicit).not.toContain('lang="en"');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user