Skip to content

Commit

Permalink
fix(nuxt): check island element instead of hydration state (#26480)
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien committed Mar 26, 2024
1 parent 1dbd46e commit fd7d9d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/nuxt/src/app/components/nuxt-island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ export default defineComponent({
components: {}
}

if (nuxtApp.isHydrating) {
if (instance.vnode.el) {
payloads.slots = toRaw(nuxtApp.payload.data[`${props.name}_${hashId.value}`])?.slots ?? {}
payloads.components = toRaw(nuxtApp.payload.data[`${props.name}_${hashId.value}`])?.components ?? {}
}

const ssrHTML = ref<string>('')

if (import.meta.client && nuxtApp.isHydrating) {
ssrHTML.value = getFragmentHTML(instance.vnode?.el ?? null, true)?.join('') || ''
if (import.meta.client && instance.vnode?.el) {
ssrHTML.value = getFragmentHTML(instance.vnode.el, true)?.join('') || ''
const key = `${props.name}_${hashId.value}`
nuxtApp.payload.data[key] ||= {}
nuxtApp.payload.data[key].html = ssrHTML.value
Expand Down Expand Up @@ -250,7 +250,7 @@ export default defineComponent({
// this is used to force trigger Teleport when vue makes the diff between old and new node
const isKeyOdd = teleportKey.value === 0 || !!(teleportKey.value && !(teleportKey.value % 2))

if (uid.value && html.value && (import.meta.server || props.lazy ? canTeleport : mounted.value || nuxtApp.isHydrating)) {
if (uid.value && html.value && (import.meta.server || props.lazy ? canTeleport : (mounted.value || instance.vnode?.el))) {
for (const slot in slots) {
if (availableSlots.value.includes(slot)) {
teleports.push(createVNode(Teleport,
Expand Down

0 comments on commit fd7d9d2

Please sign in to comment.