fix(nuxt): clear island uid before saving into the payload (#30767)

This commit is contained in:
Julien Huang 2025-01-26 19:22:22 +01:00 committed by Daniel Roe
parent e0c47f9bf3
commit b78da56dd7
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -132,10 +132,11 @@ export default defineComponent({
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
// clear all data-island-uid to avoid conflicts when saving into payloads
nuxtApp.payload.data[key].html = ssrHTML.value.replaceAll(new RegExp(`data-island-uid="${ssrHTML.value.match(SSR_UID_RE)?.[1] || ''}"`, 'g'), `data-island-uid=""`)
}
const uid = ref<string>(ssrHTML.value.match(SSR_UID_RE)?.[1] ?? getId())
const uid = ref<string>(ssrHTML.value.match(SSR_UID_RE)?.[1] || getId())
const availableSlots = computed(() => [...ssrHTML.value.matchAll(SLOTNAME_RE)].map(m => m[1]))
const html = computed(() => {
const currentSlots = Object.keys(slots)