choojs / nanocomponent

🚃 - create performant HTML components
https://leaflet.choo.io/
MIT License
366 stars 30 forks source link

allow createElement to return DocumentFragment? #91

Open ungoldman opened 5 years ago

ungoldman commented 5 years ago

nanohtml now supports document fragments, which are very handy for returning a collection of siblings without having to wrap them in an arbitrary element.

However nanocomponent is not currently designed to handle this.

If we modify the el instanceof window.Element assert in _handleRender to also accept window.DocumentFragment, we encounter an error because nanocomponent is trying to brand the returned node (which isn't a node).

This also complicates proxying and many other things. I'm not sure how much of a rewrite this would require, but I do think it would be nice to support this feature.

Thoughts?

bcomnes commented 5 years ago

Open to ideas. I've been brainstorming the use of weakmaps as way to avoid having to look at the DOM too.

bcomnes commented 5 years ago

It may be easier to write a different component class to start out with. But also open to changes landing here.

ungoldman commented 5 years ago

I've been considering a fresh start based on things I've learned the last couple years since we started the nanocomponent journey. Maybe... the time has come.

bcomnes commented 5 years ago

https://github.com/hyperdivision/nanomorph-guard https://github.com/hyperdivision/hui

Is one such start.

ungoldman commented 5 years ago

yep just took a look at hui earlier today

bcomnes commented 5 years ago

A few others I've been looking at too:

https://github.com/Polymer/lit-element https://github.com/WebReflection/hyperHTML-Element https://github.com/WebReflection/wicked-elements https://github.com/WebReflection/lighterhtml#what-about-custom-elements- (Vanilla web components)

YerkoPalma commented 5 years ago

I have been using lit-element for a while and it is pretty cool. Also Beaker has been rebuild using lit-element

s3ththompson commented 5 years ago

or choo-hooks ;)