-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent removal of nested slots within islands (#7093)
* Prevent removal of nested slots within islands * Fix build errors
- Loading branch information
Showing
24 changed files
with
288 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
'@astrojs/preact': minor | ||
'@astrojs/svelte': minor | ||
'@astrojs/react': minor | ||
'@astrojs/solid-js': minor | ||
'@astrojs/vue': minor | ||
'astro': minor | ||
--- | ||
|
||
Prevent removal of nested slots within islands | ||
|
||
This change introduces a new flag that renderers can add called `supportsAstroStaticSlot`. What this does is let Astro know that the render is sending `<astro-static-slot>` as placeholder values for static (non-hydrated) slots which Astro will then remove. | ||
|
||
This change is completely backwards compatible, but fixes bugs caused by combining ssr-only and client-side framework components like so: | ||
|
||
```astro | ||
<Component> | ||
<div> | ||
<Component client:load> | ||
<span>Nested</span> | ||
</Component> | ||
</div> | ||
</Component> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
packages/astro/test/fixtures/astro-slots-nested/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import react from '@astrojs/react'; | ||
import preact from '@astrojs/preact'; | ||
import solid from '@astrojs/solid-js'; | ||
import svelte from '@astrojs/svelte'; | ||
import vue from '@astrojs/vue'; | ||
|
||
export default defineConfig({ | ||
integrations: [react()] | ||
integrations: [ | ||
react(), | ||
preact(), | ||
solid(), | ||
svelte(), | ||
vue() | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/astro/test/fixtures/astro-slots-nested/src/components/Inner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
export default function Inner() { | ||
return <span>Inner</span>; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/astro-slots-nested/src/components/PassesChildren.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React, { Fragment } from 'react'; | ||
|
||
export default function PassesChildren({ children }) { | ||
return <Fragment>{ children }</Fragment>; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/astro-slots-nested/src/components/PassesChildrenP.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { h, Fragment } from 'preact'; | ||
|
||
export default function PassesChildren({ children }) { | ||
return <Fragment>{ children }</Fragment>; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/astro-slots-nested/src/components/PassesChildrenS.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @jsxImportSource solid-js */ | ||
|
||
export default function PassesChildren({ children }) { | ||
return <>{ children }</>; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/astro/test/fixtures/astro-slots-nested/src/components/PassesChildrenSv.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="svelte-children"> | ||
<slot></slot> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/astro-slots-nested/src/components/PassesChildrenV.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="vue-wrapper"> | ||
<slot></slot> | ||
</div> | ||
</template> |
62 changes: 62 additions & 0 deletions
62
packages/astro/test/fixtures/astro-slots-nested/src/pages/server-component-nested.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
import PassesChildren from '../components/PassesChildren.jsx'; | ||
import PassesChildrenP from '../components/PassesChildrenP.jsx'; | ||
import PassesChildrenS from '../components/PassesChildrenS.jsx'; | ||
import PassesChildrenSv from '../components/PassesChildrenSv.svelte'; | ||
import PassesChildrenV from '../components/PassesChildrenV.vue'; | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<main> | ||
<div id="react"> | ||
<PassesChildren> | ||
<div> | ||
<PassesChildren client:load> | ||
<span>Inner children</span> | ||
</PassesChildren> | ||
</div> | ||
</PassesChildren> | ||
</div> | ||
<div id="preact"> | ||
<PassesChildrenP> | ||
<div> | ||
<PassesChildrenP client:load> | ||
<span>Inner children</span> | ||
</PassesChildrenP> | ||
</div> | ||
</PassesChildrenP> | ||
</div> | ||
<div id="solid"> | ||
<PassesChildrenS> | ||
<div> | ||
<PassesChildrenS client:load> | ||
<span>Inner children</span> | ||
</PassesChildrenS> | ||
</div> | ||
</PassesChildrenS> | ||
</div> | ||
<div id="svelte"> | ||
<PassesChildrenSv> | ||
<div> | ||
<PassesChildrenSv client:load> | ||
<span>Inner children</span> | ||
</PassesChildrenSv> | ||
</div> | ||
</PassesChildrenSv> | ||
</div> | ||
<div id="vue"> | ||
<PassesChildrenV> | ||
<div> | ||
<PassesChildrenV client:load> | ||
<span>Inner children</span> | ||
</PassesChildrenV> | ||
</div> | ||
</PassesChildrenV> | ||
</div> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.