|
|
|
|
|
by youdounderstand
3506 days ago
|
|
Do custom elements allow re-templating? It's pretty powerful to be able to separate the visual presentation of a control (i.e., markup) from the logic. Every determinate progress bar has 0..1 progress and current progress properties, but the visual representation needs to be able to vary widely in order for these elements to be truly reusable. And it would be nice to be able to change the template (including adding/removing DOM elements to it) without having to define a subclass in JS. |
|
Generally though, Custom Elements are going to create a shadow root and render some DOM into it. It's all just code, so an element subclass can use a template library, and can do things like you want, like decouple its template from its implementation.
Here's a sketch of an element that would use a template as determined by a 'template' attribute.
And you'd use it like this: