7 ms·
Web Components are really just the minimal APIs required to allow the implementation of new HTML elements. This includes things like: - Responding to being att
by djrenren 3y ago
Web Components are really just the minimal APIs required to allow the implementation of new HTML elements. This includes things like:
- Responding to being attached to the DOM
- Encapsulating DOM nodes (the Shadow DOM)
- Scoped styling (Shadow DOM + User defined stylesheets + CSS parts)
It is definitively not a templating engine. It doesn't provide any new APIs for creating DOM nodes, or mutating them a la React or handlebars or lit-html. Templating is basically the "next step up the stack". Using shadowDom.innerHTML = `...`; is basically a stand-in for having an actual templating engine.
There is work going on, developing a native templating system in the browser which may interest you. It's called the DOM Parts proposal and you can find info on it here: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/DOM-Parts.md https://github.com/WICG/webcomponents/blob/gh-pages/proposal...