3 ms·
I don't think we components were intended as a complete "framework" for writing web apps, but more for the rendering of reusable UI components. So trying to do
by mattlondon 2y ago
I don't think we components were intended as a complete "framework" for writing web apps, but more for the rendering of reusable UI components.
So trying to do MVC with just web components feels a bit weird, at least to me. You'd need something extra I think
- thomassmith65 2y agoThe problem is that the ShadowDOM is sort of the real View, and the CustomElement (judging it by its methods), is kind of a mix of a View and a Controller. Perhaps I should try making my controllers the HTMLElement subclasses, instead of my views. My gripe remains: the best approach is not obvious.
- thomassmith65 2y agoNote to whoever comes across this comment in future. So I have now explored using HTMLElement as the Controller, its shallow DOM as a data source for its Model class, and its ShadowRoot as a subclass. It is clear to me now that that design would be the most natural fit for MVC. However... it is also impossible. For whatever infuriating reason, they designed custom element's ShadowDOM class to not be subclass-able. You can neither give a ShadowDOM subclass a constructor, nor does HTMLElement reveal any mechanism to 'attach' a ShadowDOM subclass. Fantastic /s