Re: [WICG/webcomponents] Scoped Custom Element Registry: Moving elements with shadow roots between documents (#907)

@rniwa you were absolutely right, and I was very wrong on previous comments and discussions, and most of the confusion from my side was caused by a bug in chrome (https://bugs.chromium.org/p/chromium/issues/detail?id=1199886) related to the instances created by the parser after element with its shadow were moved around between documents. I hope that they fix this bug soon.

Anyhow, the situation that you explained in previous F2F meetings is indeed a problem with this proposal, because all modern browsers are readjusting accordingly when elements are moved around to use the global registry of the new owner document, and that behavior poses an interesting question with it comes to scoped registries: What will the UA do when an element with a shadow root with a scoped registry associated is moved into another document? From our previous discussions, there are a couple of alternatives:

1. "null" out the registry. technically, it is not really set to `null`, but to an empty registry of some sort so it doesn't fallback to the global one. basically, it swallow any potential issue (probably ok and aligned with the current behavior for the global registry).
2. expand the `adoptedCallback`'s behavior so when the element is moved around, if it has an associated registry, it must fulfill certain invariants to reset the registry in user-land, otherwise it throws. basically, it is a responsibility of the developer to prepare their elements for the move (probably too aggressive)

I think we should go with 1) since it is similar to what will happen today with the global registry.

-- 
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/907#issuecomment-822816392

Received on Monday, 19 April 2021 22:04:27 UTC