Skip to content

Commit 448cf57

Browse files
committed
Fix location of SolidJS pre-hydration code
* Run before hydration instead of inlining a script after each component
1 parent efa6f7d commit 448cf57

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.changeset/eight-pumas-repeat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/solid-js': patch
3+
---
4+
5+
Fix location of SolidJS pre-hydration code

packages/integrations/solid/client.js

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { sharedConfig } from 'solid-js';
22
import { hydrate, createComponent } from 'solid-js/web';
33

44
export default (element) => (Component, props, childHTML) => {
5+
// Prepare global object expected by Solid's hydration logic
6+
if (!window._$HY) {
7+
window._$HY = { events: [], completed: new WeakSet, r: {} };
8+
}
9+
// Perform actual hydration
510
let children;
611
hydrate(
712
() =>

packages/integrations/solid/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function renderToStaticMarkup(Component, props, children) {
2020
})
2121
);
2222
return {
23-
html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>`,
23+
html: html,
2424
};
2525
}
2626

0 commit comments

Comments
 (0)