[WICG/webcomponents] Alternative to customized built-in - Element custom enhancements (Issue #1000)

Highlights:

1.  Can be used during template instantiation to attach behaviors (and other aspects) to built-in and custom elements (no attributes required, as that would be inefficient -- some other way of providing a mapping to be provided).
2.  Can be used to enhance built-in and custom elements from a server rendered HTML via attributes that *ought* to start with enh- , just as custom data attributes ought to start with data-.  But realistically authors will support both enh-* and an attribute without the prefix, just as Angular does (for example).
3.  Class based, extends ElementEnhancement class.
4.  ElementEnhacement has a callback "AttachedCallback" which passes in a proxy that wraps the target element.  The proxy prevents passing in properties, or calling methods that are not defined for built-ins to be passed through to the target element (throws an error), and does the same for upgraded custom elements(?).
5.  Adds a similar property as dataset to all HTMLElements, called "enhancements", off of which template instantiation can pass properties needed by the enhancement class instance (even if the enhancement hasn't loaded yet) -- lazy property setting, in other words.
6.  Frameworks could also pass properties down to the enhancement class instance via the same mechanism.
7.  ElementEnhacement class has a callback "DetachedCallback"
8.  ElementEnhancement class provides a way of defining an attribute name to associate with the enh- prefix in each shadow DOM realm (following scoped custom element methodology), and callback for when the attribute name changes (but this should, I and suspect would be used sparingly, in favor of the enhancements property gateway).  ObservedAttributeName static property, AttributeChangedCallback method.

(More details to follow).

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

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

Received on Tuesday, 18 April 2023 13:28:11 UTC