This commit is contained in:
Yasser Lahbibi 2024-11-19 15:12:44 -05:00 committed by GitHub
commit 3976965086
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -127,13 +127,13 @@ export default defineComponent({
} }
} }
const ssrHTML = ref<string>('') const cmpKey = `${props.name}_${hashId.value}`
const ssrHTML = ref<string>(nuxtApp.payload.data[cmpKey]?.html || '')
if (import.meta.client && instance.vnode?.el) { if (import.meta.client && instance.vnode?.el && !ssrHTML.value) {
ssrHTML.value = getFragmentHTML(instance.vnode.el, true)?.join('') || '' ssrHTML.value = getFragmentHTML(instance.vnode.el, true)?.join('') || ''
const key = `${props.name}_${hashId.value}` nuxtApp.payload.data[cmpKey] ||= {}
nuxtApp.payload.data[key] ||= {} nuxtApp.payload.data[cmpKey].html = ssrHTML.value
nuxtApp.payload.data[key].html = ssrHTML.value
} }
const uid = ref<string>(ssrHTML.value.match(SSR_UID_RE)?.[1] ?? getId()) const uid = ref<string>(ssrHTML.value.match(SSR_UID_RE)?.[1] ?? getId())