Re: [WICG/webcomponents] Anonymous Custom Elements (Issue #1074)

Thank you for the encouragement @keithamus . I have a couple of follow up questions/thoughts. 

>  This would likely need non-trivial changes to the way HTMLElement constructor runs and require large refactoring of the Custom Element Registry.

I was afraid that from an implementation perspective that this might not be feasible.  I might have made it harder for myself by using custom element in the title? If we consider `<anonymous>` to be a new type of element that is not connected to custom elements at all does that change how this would related to custom element registries? Or would it still be considered a type of custom elements for implementation properties? 

> Presumably there would be no way to query it via .querySelector or CSS, unless you attach a class name or attribute to each one (kind of defeating some of the point of the anonymity, no?)

 I think that this is actually a fine compromise. The primary use case would be as an alternative to scoped element registries. So in practice you would know what the element should be. Anonymity would not be the primary goal so the name is probably not a perfect fit. 
 
 > There would be no tractable way to call outerHTML, or innerHTML on a parent.  This would probably break a lot of frameworks and libraries. Using the <anonymous> tag would mean re-attaching it could potentially change or lose its definition which seems dangerous.
 
 I am not certain I understand what the implication is, or maybe what this means. Could you elaborate?
 
> It would potentially break the design of scoped registries, as there would likely need to be special handling if your element moved to a new shadow root.

I don't really understand how scoped registries would affect this. It seems like the anonymous element would be same regardless of what exists in a custom element registry (scoped or global)? Would this be a consequence of how this feature could be implemented? The intention is that a `<anonymous>` would be introduced specifically to _not_ be affected by any element registry. 
 
 > Additionally it would be very strange for existing APIs (e.g. createElement) to be able to create <anonymous> elements presumably have no definition?
 
 In my mind this would not be stranger than `<img>` without `src`. It represents something but we don't know what until we provide all the necessary information. 
 
> Given the amount of work involved on the implementation side (very large and lots of careful refactors required) I wonder if it would be worthwhile? How problematic is giving a name to an element today? 

In my mind yes, it could be worth it. I don't pretend to know how such a thing could be implemented and what the actual cost 
 is. The fundamental change here is not so much the omission of element name as it is the use ES modules as the primary way to defined elements over element registries. 
 

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

Message ID: <WICG/webcomponents/issues/1074/2384027902@github.com>

Received on Monday, 30 September 2024 19:51:27 UTC