Re: [WICG/webcomponents] Cleaning up (undefining) custom elements? (#754)

@annevk In page, SPA style routing would also heavily rely on components being able to be unregistered. 

For example, the page has a container that loads different `text/html` content (sections) based on user input. Each section can define its own templates, and the page's JS can use these to register custom elements so that the loaded content displays correctly. 

Section A has a custom element called `hello-prompt`. When routing is implemented, the container in which the section's nodes are contained (some <div> Element), Section A's nodes are all removed, and the definition provided for `hello-prompt` from Section A's HTML and registered by the page's JS is no longer needed.

If now we load in Section B, which also has a component defined as `hello-prompt`, the page's JS will not be able to define `hello-prompt` again, since Section A had defined it when it was loaded, and even though that is no longer relevant.

As it stands, it's not possible to code the sections in a modular, segregated manner, as there's no way to avoid name conflicts. Team A, working on Section A, would need to know what Team B is writing in Section B. 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/754#issuecomment-1084670990
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/754/1084670990@github.com>

Received on Thursday, 31 March 2022 14:35:39 UTC