-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix: include slot scripts in server island response #15633
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
Changes from 4 commits
97b47f6
8c59537
09f43cc
8b26f9c
45f6c69
8e846fa
9735e88
607c8e3
3a5d9a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': patch | ||
| --- | ||
|
|
||
| Fix: include `<script>` tags from components passed as slots to `server:defer` components in the server island response | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,7 +158,20 @@ export class ServerIslandComponent { | |
| for (const name in this.slots) { | ||
| if (name !== 'fallback') { | ||
| const content = await renderSlotToString(this.result, this.slots[name]); | ||
| renderedSlots[name] = content.toString(); | ||
| let slotHtml = content.toString(); | ||
| // Append script instructions so that components passed as slots | ||
| // to server:defer components retain their scripts in the island response. | ||
| // renderSlotToString returns a SlotString (typed as string) that carries | ||
| // render instructions stripped from the HTML content. | ||
| const slotContent = content as unknown as import('./slot.js').SlotString; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you use ar regular top-level type import here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, that should work. This was an oversight and there no particular reason for this kind of import. |
||
| if (Array.isArray(slotContent.instructions)) { | ||
| for (const instruction of slotContent.instructions) { | ||
| if (instruction.type === 'script') { | ||
| slotHtml += instruction.content; | ||
| } | ||
| } | ||
| } | ||
| renderedSlots[name] = slotHtml; | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.