Skip to content

Commit

Permalink
fix(nuxt): allow omitting fallback in island response (#25296)
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien committed Jan 18, 2024
1 parent 28b58c9 commit ce7845c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
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

0 comments on commit ce7845c

Please sign in to comment.