Freak613 / 1more

MIT License
49 stars 1 forks source link

Custom elements #4

Closed mrjjwright closed 3 years ago

mrjjwright commented 3 years ago

I use custom elements backed by custom classes but I don't use shadow roots. I know, it's a bit weird but I don't like the obscurity of shadow roots but I like the semantics of custom elements and the way HTML brings and organizes values to life in a tree so I use HTML for a lot more than rendering, I build lots of logic described in custom elements. I notice you have some great support for event delegation and the like with custom elements but should I turn that off somehow or will it all work fine even though I am only using custom elements in name only?

Freak613 commented 3 years ago

I think this way should work fine, but I have to test it to be sure.

For custom elements renderer registers additional event listeners on demand, basically splitting template into separate delegation roots.

So what your use case going to have, comparing to not using custom elements this way, is to have some additional event listeners where they are not required. They still will be properly organized and handle propagation well. And by definition you won't have more listeners than if not using event delegation at all. Most probably you will end up with each custom element content working with its own delegation root. I believe you should not notice it to some degree, probably the difference in performance will be visible only in benchmarks or some hi-perf applications, and only if you start comparing it to version without using custom elements. And I think for such situations system does not need to do anything additionally. Disabling it or maintain allowlisting may potentially cause unexpected problems when you start mixing shadow root elements with regular ones, or lead to unnecessary complexity.

mrjjwright commented 3 years ago

Thank you!!