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