From 448cf5790ccb862d0a9642795dd7d12033cd1660 Mon Sep 17 00:00:00 2001 From: hippotastic <6137925+hippotastic@users.noreply.github.com> Date: Tue, 19 Apr 2022 00:00:27 +0200 Subject: [PATCH] Fix location of SolidJS pre-hydration code * Run before hydration instead of inlining a script after each component --- .changeset/eight-pumas-repeat.md | 5 +++++ packages/integrations/solid/client.js | 5 +++++ packages/integrations/solid/server.js | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/eight-pumas-repeat.md diff --git a/.changeset/eight-pumas-repeat.md b/.changeset/eight-pumas-repeat.md new file mode 100644 index 000000000000..7058e360fec4 --- /dev/null +++ b/.changeset/eight-pumas-repeat.md @@ -0,0 +1,5 @@ +--- +'@astrojs/solid-js': patch +--- + +Fix location of SolidJS pre-hydration code diff --git a/packages/integrations/solid/client.js b/packages/integrations/solid/client.js index 4424e9b98526..f85bd8a23f0b 100644 --- a/packages/integrations/solid/client.js +++ b/packages/integrations/solid/client.js @@ -2,6 +2,11 @@ import { sharedConfig } from 'solid-js'; import { hydrate, createComponent } from 'solid-js/web'; export default (element) => (Component, props, childHTML) => { + // Prepare global object expected by Solid's hydration logic + if (!window._$HY) { + window._$HY = { events: [], completed: new WeakSet, r: {} }; + } + // Perform actual hydration let children; hydrate( () => diff --git a/packages/integrations/solid/server.js b/packages/integrations/solid/server.js index ccee482eaa31..636fa50f6bc6 100644 --- a/packages/integrations/solid/server.js +++ b/packages/integrations/solid/server.js @@ -20,7 +20,7 @@ function renderToStaticMarkup(Component, props, children) { }) ); return { - html: html + ``, + html: html, }; }