summaryrefslogtreecommitdiff
path: root/packages/integrations/solid/client.js
diff options
context:
space:
mode:
authorGravatar natemoo-re <natemoo-re@users.noreply.github.com> 2022-05-31 16:47:13 +0000
committerGravatar github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-05-31 16:47:13 +0000
commite02c72f4452de76c584e06baf4696191889114bd (patch)
treea131766727dd451e71e2723cb9a2f31df137102c /packages/integrations/solid/client.js
parentc9d8b10a854739e4911cd058ccabbb60035a670e (diff)
downloadastro-e02c72f4452de76c584e06baf4696191889114bd.tar.gz
astro-e02c72f4452de76c584e06baf4696191889114bd.tar.zst
astro-e02c72f4452de76c584e06baf4696191889114bd.zip
[ci] format
Diffstat (limited to 'packages/integrations/solid/client.js')
-rw-r--r--packages/integrations/solid/client.js61
1 files changed, 31 insertions, 30 deletions
diff --git a/packages/integrations/solid/client.js b/packages/integrations/solid/client.js
index 005f3c980..867d951c6 100644
--- a/packages/integrations/solid/client.js
+++ b/packages/integrations/solid/client.js
@@ -1,36 +1,37 @@
import { sharedConfig } from 'solid-js';
import { hydrate, render, createComponent } from 'solid-js/web';
-export default (element) => (Component, props, childHTML, { client }) => {
- // Prepare global object expected by Solid's hydration logic
- if (!window._$HY) {
- window._$HY = { events: [], completed: new WeakSet(), r: {} };
- }
- if (!element.hasAttribute('ssr')) return;
+export default (element) =>
+ (Component, props, childHTML, { client }) => {
+ // Prepare global object expected by Solid's hydration logic
+ if (!window._$HY) {
+ window._$HY = { events: [], completed: new WeakSet(), r: {} };
+ }
+ if (!element.hasAttribute('ssr')) return;
- const fn = client === 'only' ? render : hydrate;
-
- // Perform actual hydration
- let children;
- fn(
- () =>
- createComponent(Component, {
- ...props,
- get children() {
- if (childHTML != null) {
- // hydrating
- if (sharedConfig.context) {
- children = element.querySelector('astro-fragment');
- }
+ const fn = client === 'only' ? render : hydrate;
+
+ // Perform actual hydration
+ let children;
+ fn(
+ () =>
+ createComponent(Component, {
+ ...props,
+ get children() {
+ if (childHTML != null) {
+ // hydrating
+ if (sharedConfig.context) {
+ children = element.querySelector('astro-fragment');
+ }
- if (children == null) {
- children = document.createElement('astro-fragment');
- children.innerHTML = childHTML;
+ if (children == null) {
+ children = document.createElement('astro-fragment');
+ children.innerHTML = childHTML;
+ }
}
- }
- return children;
- },
- }),
- element
- );
-};
+ return children;
+ },
+ }),
+ element
+ );
+ };