Re: [WICG/webcomponents] [scoped-registries] Interaction with declarative shadow DOM (#914)

> orphaned instance properties, event listeners, attributes, shadow children, etc

The CE author would clean up event listeners in `disconnectedCallback`.

I believe DOM Mutation events could be improved (batched like MutationObserver if not already), and that `upgrade` and `downgrade` events could be added. This would make it _easy_ for outside users to also clean up their own event handlers.

Dangling properties and attributes are fine: a user would need to know that they have swapped the definition of an element, and they should set new properties or attributes after the re-upgrade (or leave them if the new definition is compatible, so similar to swapping implementations of an interface, but at runtime).

As for Shadow DOM, that can be handled similar to declarative shadow DOM and ElementInternals: the re-upgraded element will already have a shadow root and the root can be re-used just like in the DSD case. Maybe there would need to be an additional way to detect re-upgrade vs DSD (so to either overwrite the root's content, or re-use the root's content). If not, then the only sure way is to always overwrite the root's content and never re-use it.

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

Received on Monday, 22 March 2021 18:05:58 UTC