Hacker News new | ask | show | jobs
by justsomeuser 1189 days ago
How do you manage changing state overtime? Do you re-render the whole template?

Can templates be nested?

1 comments

You use standard DOM operations to update state, like innerText and classList.add, defined inside the JS class that orchestrates the component.

Nesting works using the same concept. A parent template either picks one of its child nodes using this.fragment.querySelector or using document.createElement to mount a child template to. You then use this.addChild to opt into garbage collection.