Re: [WICG/webcomponents] Proposal: Custom attributes for all elements, enhancements for more complex use cases (Issue #1029)

The API is nice, but HTML engines do have an attribute node and [Attr type](https://developer.mozilla.org/en-US/docs/Web/API/Attr)
```ts
interface Attr extends Node {
```
Based on this concept, in `custom-element` it is exposed via declarative syntax:
```html
<custom-element tag="dce-link" hidden="">
            <attribute name="p1">default_P1                </attribute>
            <attribute name="p2" select="'always_p2'"></attribute>
            <attribute name="p3" select="//p3 ?? 'def_P3' "></attribute>
            p1:{$p1} <br> p2: {$p2} <br> p3: {$p3}
</custom-element>
<dce-link></dce-link>
<dce-link p1="123" p3="qwe"></dce-link> 
```
More [live samles](https://unpkg.com/@epa-wg/custom-element@0.0.21/demo/parameters.html)

As for imperative declaration, the `class Attribute` seems fine to me, but only trouble it is already a part of all browser implementations. Instead of trying to propose own, perhaps worth to explore existing `Attribute` implementation in WebKit?
The only action in this case would be 
* make it part of HTML parser, i.e. add to HTML5 
* add the functionality of observed attributes.


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

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

Received on Wednesday, 15 May 2024 16:49:20 UTC