summaryrefslogtreecommitdiff
path: root/packages/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations')
-rw-r--r--packages/integrations/preact/client.js2
-rw-r--r--packages/integrations/solid/client.js61
-rw-r--r--packages/integrations/vue/client.js35
3 files changed, 50 insertions, 48 deletions
diff --git a/packages/integrations/preact/client.js b/packages/integrations/preact/client.js
index 6ff40d2ae..12c5666df 100644
--- a/packages/integrations/preact/client.js
+++ b/packages/integrations/preact/client.js
@@ -7,4 +7,4 @@ export default (element) => (Component, props, children) => {
h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
element
);
-}
+};
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
+ );
+ };
diff --git a/packages/integrations/vue/client.js b/packages/integrations/vue/client.js
index 4832a9847..c6206fe51 100644
--- a/packages/integrations/vue/client.js
+++ b/packages/integrations/vue/client.js
@@ -1,21 +1,22 @@
import { h, createSSRApp, createApp } from 'vue';
import StaticHtml from './static-html.js';
-export default (element) => (Component, props, children, { client }) => {
- delete props['class'];
- if (!element.hasAttribute('ssr')) return;
+export default (element) =>
+ (Component, props, children, { client }) => {
+ delete props['class'];
+ if (!element.hasAttribute('ssr')) return;
- // Expose name on host component for Vue devtools
- const name = Component.name ? `${Component.name} Host` : undefined;
- const slots = {};
- if (children != null) {
- slots.default = () => h(StaticHtml, { value: children });
- }
- if (client === 'only') {
- const app = createApp({ name, render: () => h(Component, props, slots) });
- app.mount(element, false);
- } else {
- const app = createSSRApp({ name, render: () => h(Component, props, slots) });
- app.mount(element, true);
- }
-};
+ // Expose name on host component for Vue devtools
+ const name = Component.name ? `${Component.name} Host` : undefined;
+ const slots = {};
+ if (children != null) {
+ slots.default = () => h(StaticHtml, { value: children });
+ }
+ if (client === 'only') {
+ const app = createApp({ name, render: () => h(Component, props, slots) });
+ app.mount(element, false);
+ } else {
+ const app = createSSRApp({ name, render: () => h(Component, props, slots) });
+ app.mount(element, true);
+ }
+ };