Skip to content

Commit

Permalink
perf(nuxt): remove some line breaks when rendering html (#24888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost committed Jan 4, 2024
1 parent 3cdef69 commit 13c42d3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/nuxt/src/core/runtime/nitro/renderer.ts
Expand Up @@ -412,9 +412,9 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
// Create render context
const htmlContext: NuxtRenderHTMLContext = {
island: Boolean(islandContext),
htmlAttrs: [htmlAttrs],
htmlAttrs: htmlAttrs ? [htmlAttrs] : [],
head: normalizeChunks([headTags, ssrContext.styles]),
bodyAttrs: [bodyAttrs],
bodyAttrs: bodyAttrs ? [bodyAttrs] : [],
bodyPrepend: normalizeChunks([bodyTagsOpen, ssrContext.teleports?.body]),
body: [process.env.NUXT_COMPONENT_ISLANDS ? replaceClientTeleport(ssrContext, replaceServerOnlyComponentsSlots(ssrContext, _rendered.html)) : _rendered.html],
bodyAppend: [bodyTags]
Expand Down Expand Up @@ -502,11 +502,11 @@ function joinAttrs (chunks: string[]) {
}

function renderHTMLDocument (html: NuxtRenderHTMLContext) {
return `<!DOCTYPE html>
<html ${joinAttrs(html.htmlAttrs)}>
<head>${joinTags(html.head)}</head>
<body ${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body>
</html>`
return '<!DOCTYPE html>'
+ `<html${joinAttrs(html.htmlAttrs)}>`
+ `<head>${joinTags(html.head)}</head>`
+ `<body${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body>`
+ '</html>'
}

async function renderInlineStyles (usedModules: Set<string> | string[]): Promise<Style[]> {
Expand Down

0 comments on commit 13c42d3

Please sign in to comment.