Hacker News new | ask | show | jobs
by nidificate 2429 days ago
This already exists. They are called custom elements.

https://html.spec.whatwg.org/multipage/custom-elements.html#...

https://github.com/w3c/webcomponents/

https://developer.mozilla.org/en-US/docs/Web/Web_Components/...

1 comments

Yep, to some degree. Though what I would love in an xml-based UI description language is the ability to opt into default system behaviors, while maintaining the ability to use whatever semantic naming convention that fits my application.

I wrote this code in another comment, but imagine if you could hook functionality to an element via defined attributes. With custom elements, you have to add the functionality via a script, and they aren't system functions (from what I can remember, I may be wrong).

  <LabelList list>
    <LabelItem label listItem>
    </LabelItem>
  </LabelList>
In the above code:

- the LabelList element hooks into the systems "list" behavior

- the LabelItem element hooks into the systems "label" behavior

- the LabelItem element hooks into the systems "listItem" behavior

Maybe the is="" attribute gets you partway there?

    <ul is="label-list">
        <li is="list-item">foo</li>
    </ul>
EDIT: google's documentation: https://developers.google.com/web/fundamentals/web-component...