@@ -104,15 +104,21 @@ function constructIslandClient(name, importPath) {
104104 import { render, h } from 'preact';
105105
106106${ readFileSync ( resolve ( __dirname , './client/helpers.js' ) , 'utf8' ) }
107+
108+ customElements.define("${ islandName } ", class Island${ name } extends HTMLElement {
109+ constructor(){
110+ super();
111+ }
112+
113+ async connectedCallback() {
114+ const c = await import(${ JSON . stringify ( importPath ) } );
115+ const props = JSON.parse(this.dataset.props || '{}');
116+ mergePropsWithDOM(this,props);
117+ render(restoreTree(c.default, props), this, this)
118+ }
119+ })
107120
108- customElements.define("${ islandName } ", class Island${ name } extends HTMLElement {
109- async connectedCallback() {
110- const c = await import(${ JSON . stringify ( importPath ) } );
111- const props = JSON.parse(this.dataset.props || '{}');
112- mergePropsWithDOM(this,props);
113- render(restoreTree(c.default, props), this, this)
114- }
115- })`
121+ `
116122}
117123
118124/**
@@ -145,7 +151,7 @@ function constructIslandServer(ast, name, options = {}) {
145151 code = `
146152 export default function Island${ name } (props) {
147153 return h(Fragment,{},
148- h("${ islandName } ",{ "data-props": JSON.stringify(props) },h(${ name } , props)),
154+ h("${ islandName } ",{ "data-props": JSON.stringify(props) }, h(${ name } ,props)),
149155 h("script",{async:true, src:"${ path . join (
150156 baseURL ,
151157 scriptBaseName
0 commit comments