diff options
Diffstat (limited to 'packages/integrations/solid/client.js')
-rw-r--r-- | packages/integrations/solid/client.js | 61 |
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 + ); + }; |