fix: meta charSet -> charset (#1875)

This commit is contained in:
Marvin Hagemeister
2023-10-06 15:59:13 +02:00
committed by GitHub
parent 77ed10078c
commit e9717ed911
16 changed files with 152 additions and 38 deletions
+2 -2
View File
@@ -82,7 +82,7 @@ export function setRenderState(state: RenderState | null): void {
const supportsUnstableComments = renderToString(h(Fragment, {
// @ts-ignore unstable features not supported in types
UNSTABLE_comment: "foo",
})) !== "";
}) as VNode) !== "";
if (!supportsUnstableComments) {
console.warn(
@@ -347,7 +347,7 @@ options.__b = (vnode: VNode<Record<string, unknown>>) => {
);
}
const child = h(originalType, props);
const child = h(originalType, props) as VNode;
patched.add(child);
islandProps.push(props);
+16 -8
View File
@@ -1,7 +1,14 @@
import { RenderState } from "./state.ts";
import { setRenderState } from "./preact_hooks.ts";
import { renderToString } from "preact-render-to-string";
import { Fragment, h, isValidElement, toChildArray, VNode } from "preact";
import {
ComponentType,
Fragment,
h,
isValidElement,
toChildArray,
VNode,
} from "preact";
import { HEAD_CONTEXT } from "../../runtime/head.ts";
import { CSP_CONTEXT } from "../../runtime/csp.ts";
@@ -13,12 +20,12 @@ export function renderHtml(state: RenderState) {
const componentStack = state.componentStack;
try {
const routeComponent = componentStack[componentStack.length - 1];
let finalComp = h(routeComponent, state.routeOptions);
let finalComp = h(routeComponent, state.routeOptions) as VNode;
// Skip page component
let i = componentStack.length - 1;
while (i--) {
const component = componentStack[i];
const component = componentStack[i] as ComponentType;
const curComp = finalComp;
finalComp = h(component, {
@@ -26,7 +33,8 @@ export function renderHtml(state: RenderState) {
Component() {
return curComp;
},
});
// deno-lint-ignore no-explicit-any
} as any) as VNode;
}
const app = h(
@@ -37,12 +45,12 @@ export function renderHtml(state: RenderState) {
value: state.headVNodes,
children: finalComp,
}),
);
) as VNode;
let html = renderToString(app);
for (const [id, children] of state.slots.entries()) {
const slotHtml = renderToString(h(Fragment, null, children));
const slotHtml = renderToString(h(Fragment, null, children) as VNode);
const templateId = id.replace(/:/g, "-");
html += `<template id="${templateId}">${slotHtml}</template>`;
}
@@ -103,7 +111,7 @@ export function renderOuterDocument(
h(
"head",
docHead,
!renderedHtmlTag ? h("meta", { charSet: "utf-8" }) : null,
!renderedHtmlTag ? h("meta", { charset: "utf-8" }) : null,
!renderedHtmlTag
? (h("meta", {
name: "viewport",
@@ -124,7 +132,7 @@ export function renderOuterDocument(
...docBody,
dangerouslySetInnerHTML: { __html: opts.bodyHtml },
}),
);
) as VNode;
try {
setRenderState(state);