yelouafi / petit-dom

minimalist virtual dom library
MIT License
501 stars 36 forks source link

Support for JSX Fragment #34

Closed elclanrs closed 3 years ago

elclanrs commented 4 years ago

Is there a way to use fragments with petit-dom?

export default <>
  <h1></h1>
  <h2></h2>
</>;

I'm trying to use petit-dom to render into a shadow-dom, and it works great, but having a single parent is not ideal because my shadow dom ends up having an unnecessary wrapper element. I know other vdom libraries support this, but I'm not sure about the tradeoffs, if any.

elclanrs commented 4 years ago

I just realized this is partly a duplicate of https://github.com/yelouafi/petit-dom/issues/1. As far as I know, arrays of vnodes need to be supported to support Fragment in JSX.

yelouafi commented 3 years ago

Fragments (and nested arrays as well) are supported in v0.4.1

yisar commented 3 years ago

@yelouafi I see that the new implementation has abandoned the O(nd) algorithm, is there any trade-off, thank you.