Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nuxt): make slot response fallback property undefineable #25296

Merged
merged 4 commits into from Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/components/nuxt-island.ts
Expand Up @@ -134,7 +134,7 @@ export default defineComponent({

return html.replaceAll(SLOT_FALLBACK_RE, (full, slotName) => {
if (!currentSlots.includes(slotName)) {
return full + payloadSlots[slotName]?.fallback ?? ''
return full + (payloadSlots[slotName]?.fallback || '')
}
return full
})
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/src/core/runtime/nitro/renderer.ts
Expand Up @@ -64,7 +64,7 @@ export interface NuxtIslandContext {

export interface NuxtIslandSlotResponse {
props: Array<unknown>
fallback: string
fallback?: string
}
export interface NuxtIslandClientResponse {
html: string
Expand Down Expand Up @@ -626,7 +626,7 @@ function getSlotIslandResponse (ssrContext: NuxtSSRContext): NuxtIslandResponse[
for (const slot in ssrContext.islandContext.slots) {
response[slot] = {
...ssrContext.islandContext.slots[slot],
fallback: ssrContext.teleports?.[`island-fallback=${slot}`] || ''
fallback: ssrContext.teleports?.[`island-fallback=${slot}`]
}
}
return response
Expand Down
2 changes: 0 additions & 2 deletions test/basic.test.ts
Expand Up @@ -1825,7 +1825,6 @@ describe('component islands', () => {
"html": "<div data-island-uid><div> count is above 2 </div><!--[--><div style="display: contents;" data-island-uid data-island-slot="default"></div><!--]--> that was very long ... <div id="long-async-component-count">3</div> <!--[--><div style="display: contents;" data-island-uid data-island-slot="test"></div><!--]--><p>hello world !!!</p><!--[--><div style="display: contents;" data-island-uid data-island-slot="hello"></div><!--teleport start--><!--teleport end--><!--]--><!--[--><div style="display: contents;" data-island-uid data-island-slot="fallback"></div><!--teleport start--><!--teleport end--><!--]--></div>",
"slots": {
"default": {
"fallback": "",
"props": [],
},
"fallback": {
Expand Down Expand Up @@ -1854,7 +1853,6 @@ describe('component islands', () => {
],
},
"test": {
"fallback": "",
"props": [
{
"count": 3,
Expand Down