Skip to content

Commit

Permalink
fix: islands are not being rendered correctly (#8580)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Raj Jain authored Sep 18, 2023
1 parent fca6892 commit 8d36116
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-trainers-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

add hide to style & script generated for island
6 changes: 3 additions & 3 deletions packages/astro/src/runtime/server/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SSRResult } from '../../@types/astro.js';
import islandScript from './astro-island.prebuilt.js';

const ISLAND_STYLES = `<style>astro-island,astro-slot,astro-static-slot{display:contents}</style>`;
const ISLAND_STYLES = `<style style="display:none">astro-island,astro-slot,astro-static-slot{display:contents}</style>`;

export function determineIfNeedsHydrationScript(result: SSRResult): boolean {
if (result._metadata.hasHydrationScript) {
Expand Down Expand Up @@ -36,12 +36,12 @@ export function getPrescripts(result: SSRResult, type: PrescriptType, directive:
// deps to be loaded immediately.
switch (type) {
case 'both':
return `${ISLAND_STYLES}<script>${getDirectiveScriptText(
return `${ISLAND_STYLES}<script style="display:none">${getDirectiveScriptText(
result,
directive
)};${islandScript}</script>`;
case 'directive':
return `<script>${getDirectiveScriptText(result, directive)}</script>`;
return `<script style="display:none">${getDirectiveScriptText(result, directive)}</script>`;
}
return '';
}

0 comments on commit 8d36116

Please sign in to comment.