reshape/preact-components

Option to retain wrapping HTML Element

Opened this issue · 0 comments

It'd be great if there could be a flag while rendering these components which would cause the rendered preact output to be placed inside the element, rather than replace the element.

e.g.

<my-component foo='bar' />

would become:

<my-component>
  <p>the value of foo is "bar"</p>
</my-component>

this would mean the HTML author could treat the entire HTML as 'real' and target the wrapper DOM element with CSS / JS etc. without having to think about it potentially disappearing. It also means its just slightly less 'magical' IMO.

Another benefit (potentially out of scope) would mean that if someone wanted to then use real Custom Elements client side, they could import it on the client and the HTML would get automatically upgraded. This however I'm a bit unsure about, as you'd likely want an easy way of duplicating the Preact functionality in the Custom Element definition, which I'm unsure how to go about.

Thoughts?