Skip to content

Commit

Permalink
fix: detect invalid html
Browse files Browse the repository at this point in the history
fixes #4618
  • Loading branch information
manucorporat committed Jun 27, 2023
1 parent ce17355 commit b687cdd
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit b687cdd

Please sign in to comment.