Skip to content

Commit

Permalink
fix: remove teleports and root from components islands as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
manniL committed Feb 18, 2024
1 parent ed93620 commit dd2e305
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/nuxt/src/core/runtime/nitro/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,14 @@ async function getIslandContext (event: H3Event): Promise<NuxtIslandContext> {
return ctx
}

const HAS_APP_TELEPORTS = appTeleportTag && appTeleportId

const PAYLOAD_URL_RE = process.env.NUXT_JSON_PAYLOADS ? /\/_payload(\.[a-zA-Z0-9]+)?.json(\?.*)?$/ : /\/_payload(\.[a-zA-Z0-9]+)?.js(\?.*)?$/
const ROOT_NODE_REGEX = new RegExp(`^<${appRootTag}${appRootId ? ` id="${appRootId}"` : ''}>([\\s\\S]*)</${appRootTag}>$`)
const APP_TELEPORT_REGEX_STRING = HAS_APP_TELEPORTS ? `<${appTeleportTag} id="${appTeleportId}">[\\s\\S]*</${appTeleportTag}>` : ''
const ROOT_NODE_REGEX = new RegExp(`^<${appRootTag}${appRootId ? ` id="${appRootId}"` : ''}>([\\s\\S]*)</${appRootTag}>${APP_TELEPORT_REGEX_STRING}$`)
const RENDER_TEMPLATE_FN = (html: string) => {
const base = `<${appRootTag}${appRootId ? ` id="${appRootId}"` : ''}>${html}</${appRootTag}>`
const nuxtTeleports = appTeleportTag && appTeleportId ? `<${appTeleportTag} id="${appTeleportId}"></${appTeleportTag}>` : ''
const nuxtTeleports =HAS_APP_TELEPORTS ? `<${appTeleportTag} id="${appTeleportId}"></${appTeleportTag}>` : ''
return base + nuxtTeleports
}

Expand Down

0 comments on commit dd2e305

Please sign in to comment.