mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
13b782f421
* fix: solid nested hydration * Create ten-rice-unite.md Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
25 lines
593 B
JavaScript
25 lines
593 B
JavaScript
import { sharedConfig } from 'solid-js';
|
|
import { hydrate, createComponent } from 'solid-js/web';
|
|
|
|
export default (element) => (Component, props, childHTML) => {
|
|
let children;
|
|
hydrate(
|
|
() =>
|
|
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
|
|
);
|
|
};
|