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

> As I have [previously stated](https://github.com/WICG/webcomponents/issues/754#issuecomment-781749398), there are a [number of questions](https://github.com/WICG/webcomponents/issues/754#issuecomment-557774809) that need to be answered for this to work that will be resolved once the scoped custom element registry is well defined.
> 
> So folks who are interested in this cleanup capability should also focus on the [scoped custom element registry](https://github.com/WICG/webcomponents/issues/716) since having that feature not only addresses most of important use cases raised in this issue, having a concrete of scoped registry would pave a way to define how this cleanup feature will work.

I don't think scoping resolves cleaning the use case I mentioned above, as Section A can be removed from page then later added again. Presumably the scope would have been the same unless the page itself implemented some scope naming rules. Otherwise, there will still be an error redeclaring the same component. 

RE your edge cases, I'd propose something like `dismount(true)` to unregister when there are still modes of the custom element in place, or `dismount()` when that element isn't used. Error is returned when 'dismount()' is called when that element is still in DOM. When a dismounted element is still in DOM, it should be treated as a custom element that had never been registered. All internal states and methods should be lost. 

All this though is something I think we should only work on after the issue is reopened, and @annevk wants us to demonstrate use case first. 



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

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

Received on Friday, 1 April 2022 07:10:16 UTC