@islands/hydration
Version:
Hydration utilities for îles
27 lines (25 loc) • 870 B
JavaScript
import {
onDispose
} from "./chunk-AX6GSPTT.js";
// preact.ts
import { h, render, toChildArray } from "preact";
function createIsland(component, id, el, props, slots) {
render(createElement(component, props, slots), el);
if (import.meta.env.DISPOSE_ISLANDS)
onDispose(id, () => render(null, el));
if (import.meta.env.DEV)
window.__ILE_DEVTOOLS__?.onHydration({ id, el, props, slots, component, framework: "preact" });
}
var IslandContent = (props) => {
return h("iles-content", { dangerouslySetInnerHTML: { __html: props.content } });
};
IslandContent.shouldComponentUpdate = () => false;
function createElement(component, props, slots) {
const content = slots?.default;
const children = content ? toChildArray(h(IslandContent, { content })) : null;
return h(component, props, children);
}
export {
createElement,
createIsland as default
};