summaryrefslogtreecommitdiff
path: root/packages/integrations/preact/src/static-html.ts
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2023-05-17 10:18:04 -0400
committerGravatar GitHub <noreply@github.com> 2023-05-17 10:18:04 -0400
commit3d525efc95cfb2deb5d9e04856d02965d66901c9 (patch)
treeaf1973aede0d2950d94b7ebfc957770be214446c /packages/integrations/preact/src/static-html.ts
parente9fc2c2213036d47cd30a47a6cdad5633481a0f8 (diff)
downloadastro-3d525efc95cfb2deb5d9e04856d02965d66901c9.tar.gz
astro-3d525efc95cfb2deb5d9e04856d02965d66901c9.tar.zst
astro-3d525efc95cfb2deb5d9e04856d02965d66901c9.zip
Prevent removal of nested slots within islands (#7093)
* Prevent removal of nested slots within islands * Fix build errors
Diffstat (limited to 'packages/integrations/preact/src/static-html.ts')
-rw-r--r--packages/integrations/preact/src/static-html.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/packages/integrations/preact/src/static-html.ts b/packages/integrations/preact/src/static-html.ts
index e1127d226..c1e44515f 100644
--- a/packages/integrations/preact/src/static-html.ts
+++ b/packages/integrations/preact/src/static-html.ts
@@ -1,5 +1,11 @@
import { h } from 'preact';
+type Props = {
+ value: string;
+ name?: string;
+ hydrate?: boolean;
+}
+
/**
* Astro passes `children` as a string of HTML, so we need
* a wrapper `div` to render that content as VNodes.
@@ -7,9 +13,10 @@ import { h } from 'preact';
* As a bonus, we can signal to Preact that this subtree is
* entirely static and will never change via `shouldComponentUpdate`.
*/
-const StaticHtml = ({ value, name }: { value: string; name?: string }) => {
+const StaticHtml = ({ value, name, hydrate }: Props) => {
if (!value) return null;
- return h('astro-slot', { name, dangerouslySetInnerHTML: { __html: value } });
+ const tagName = hydrate === false ? 'astro-static-slot' : 'astro-slot';
+ return h(tagName, { name, dangerouslySetInnerHTML: { __html: value } });
};
/**