summaryrefslogtreecommitdiff
path: root/packages/integrations/preact/client.js
blob: e2f4ca80353f5b9ea20bdb45eb7068ebe83d51ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { h, render } from 'preact';
import StaticHtml from './static-html.js';

export default (element) => (Component, props, { default: children, ...slotted }) => {
	if (!element.hasAttribute('ssr')) return;
	for (const [key, value] of Object.entries(slotted)) {
		props[key] = h(StaticHtml, { value, name: key });
	}
	render(
		h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
		element
	);
};