Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: detect invalid html #4623

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/qwik/src/core/render/ssr/render-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ export const _renderSSR = async (node: JSXNode, opts: RenderSSROptions) => {
const doc = createDocument();
const rCtx = createRenderContext(doc as any, containerState);
const headNodes = opts.beforeContent ?? [];
if (qDev) {
if (
root in phasingContent ||
root in emptyElements ||
root in tableContent ||
root in startPhasingContent ||
root in invisibleElements
) {
throw new Error(
`The "containerTagName" can not be "${root}". Please choose a different tag name like: "div", "html", "custom-container".`
);
}
}
const ssrCtx: SSRContext = {
$static$: {
$contexts$: [],
Expand Down Expand Up @@ -701,6 +714,11 @@ This goes against the HTML spec: https://html.spec.whatwg.org/multipage/dom.html
node
);
}
} else if (tagName in htmlContent) {
throw createJSXError(
`<${tagName}> can not be rendered because its parent is not a <html> element. Make sure the 'containerTagName' is set to 'html' in entry.ssr.tsx`,
node
);
}
if (tagName in startPhasingContent) {
flags |= IS_PHASING;
Expand Down