summaryrefslogtreecommitdiff
path: root/packages/integrations/solid/server.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-08-10 15:10:31 -0400
committerGravatar GitHub <noreply@github.com> 2022-08-10 15:10:31 -0400
commit0af5aa7a3b2a858c6b6cdbeda46bc3d90be1250f (patch)
treeb4f9dc145005c31c0d0f4cce66a30130908f650c /packages/integrations/solid/server.js
parent58941e93c396bf35becc7431e1743afbaad6dd69 (diff)
downloadastro-0af5aa7a3b2a858c6b6cdbeda46bc3d90be1250f.tar.gz
astro-0af5aa7a3b2a858c6b6cdbeda46bc3d90be1250f.tar.zst
astro-0af5aa7a3b2a858c6b6cdbeda46bc3d90be1250f.zip
Fix solid recursion bug (#4215)
* Fix solid recursion bug * Fix types * Remove debug code * Remove logging from e2e test
Diffstat (limited to 'packages/integrations/solid/server.js')
-rw-r--r--packages/integrations/solid/server.js31
1 files changed, 0 insertions, 31 deletions
diff --git a/packages/integrations/solid/server.js b/packages/integrations/solid/server.js
deleted file mode 100644
index 2398ec317..000000000
--- a/packages/integrations/solid/server.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import { renderToString, ssr, createComponent } from 'solid-js/web';
-
-const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
-
-function check(Component, props, children) {
- if (typeof Component !== 'function') return false;
- const { html } = renderToStaticMarkup(Component, props, children);
- return typeof html === 'string';
-}
-
-function renderToStaticMarkup(Component, props, { default: children, ...slotted }) {
- const slots = {};
- for (const [key, value] of Object.entries(slotted)) {
- const name = slotName(key);
- slots[name] = ssr(`<astro-slot name="${name}">${value}</astro-slot>`);
- }
- // Note: create newProps to avoid mutating `props` before they are serialized
- const newProps = {
- ...props,
- ...slots,
- // In Solid SSR mode, `ssr` creates the expected structure for `children`.
- children: children != null ? ssr(`<astro-slot>${children}</astro-slot>`) : children,
- };
- const html = renderToString(() => createComponent(Component, newProps));
- return { html };
-}
-
-export default {
- check,
- renderToStaticMarkup,
-};