2022-04-06 19:42:01 +00:00
|
|
|
import { sharedConfig } from 'solid-js';
|
2022-03-18 22:35:45 +00:00
|
|
|
import { hydrate, createComponent } from 'solid-js/web';
|
|
|
|
|
|
|
|
export default (element) => (Component, props, childHTML) => {
|
|
|
|
let children;
|
2022-04-06 19:42:01 +00:00
|
|
|
hydrate(
|
|
|
|
() =>
|
|
|
|
createComponent(Component, {
|
|
|
|
...props,
|
|
|
|
get children() {
|
|
|
|
if (childHTML != null) {
|
|
|
|
// hydrating
|
|
|
|
if (sharedConfig.context) children = element.querySelector('astro-fragment');
|
2022-03-18 22:35:45 +00:00
|
|
|
|
2022-04-06 19:42:01 +00:00
|
|
|
if (children == null) {
|
|
|
|
children = document.createElement('astro-fragment');
|
|
|
|
children.innerHTML = childHTML;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return children;
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
element
|
|
|
|
);
|
2022-03-18 22:35:45 +00:00
|
|
|
};
|