diff --git a/packages/astro/e2e/nested-in-solid.test.js b/packages/astro/e2e/nested-in-solid.test.js index 11f97f9d8..791c36615 100644 --- a/packages/astro/e2e/nested-in-solid.test.js +++ b/packages/astro/e2e/nested-in-solid.test.js @@ -94,4 +94,3 @@ test.describe('Nested Frameworks in Solid', () => { await expect(count, 'count incremented by 1').toHaveText('1'); }); }); - diff --git a/packages/astro/src/runtime/client/events.ts b/packages/astro/src/runtime/client/events.ts index aa8e92736..fd7a31f2c 100644 --- a/packages/astro/src/runtime/client/events.ts +++ b/packages/astro/src/runtime/client/events.ts @@ -1,11 +1,11 @@ const HYDRATE_KEY = `astro:hydrate`; function debounce any>(cb: T, wait = 20) { - let h = 0; - let callable = (...args: any) => { - clearTimeout(h); - h = setTimeout(() => cb(...args), wait) as unknown as number; - }; - return callable as T; + let h = 0; + let callable = (...args: any) => { + clearTimeout(h); + h = setTimeout(() => cb(...args), wait) as unknown as number; + }; + return callable as T; } export const notify = debounce(() => { @@ -14,7 +14,8 @@ export const notify = debounce(() => { } }); -export const listen = (cb: (...args: any[]) => any) => window.addEventListener(HYDRATE_KEY, cb, { once: true }); +export const listen = (cb: (...args: any[]) => any) => + window.addEventListener(HYDRATE_KEY, cb, { once: true }); if (!(window as any)[HYDRATE_KEY]) { if ('MutationObserver' in window) { diff --git a/packages/astro/src/runtime/client/idle.ts b/packages/astro/src/runtime/client/idle.ts index ff37585e6..a9b7b39a0 100644 --- a/packages/astro/src/runtime/client/idle.ts +++ b/packages/astro/src/runtime/client/idle.ts @@ -14,7 +14,7 @@ export default async function onIdle( let hydrate: Awaited>; async function idle() { - listen(idle) + listen(idle); const cb = async () => { const roots = document.querySelectorAll(`astro-root[ssr][uid="${astroId}"]`); if (roots.length === 0) return; diff --git a/packages/astro/src/runtime/client/media.ts b/packages/astro/src/runtime/client/media.ts index cd4415879..ab1fb8dc8 100644 --- a/packages/astro/src/runtime/client/media.ts +++ b/packages/astro/src/runtime/client/media.ts @@ -13,7 +13,7 @@ export default async function onMedia( let hydrate: Awaited>; async function media() { - listen(media) + listen(media); const cb = async () => { const roots = document.querySelectorAll(`astro-root[ssr][uid="${astroId}"]`); if (roots.length === 0) return; diff --git a/packages/astro/src/runtime/client/visible.ts b/packages/astro/src/runtime/client/visible.ts index 9202d8c72..dacb756eb 100644 --- a/packages/astro/src/runtime/client/visible.ts +++ b/packages/astro/src/runtime/client/visible.ts @@ -16,7 +16,7 @@ export default async function onVisible( let hydrate: Awaited>; async function visible() { - listen(visible) + listen(visible); const roots = document.querySelectorAll(`astro-root[ssr][uid="${astroId}"]`); const cb = async () => { if (roots.length === 0) return; 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; - if (children == null) { - children = document.createElement('astro-fragment'); - children.innerHTML = childHTML; + // 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; + } } - } - 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); + } + };