4 ms·
As someone who has only used html (as in, no other xml-based UI), I'm really curious why it's necessary to even define the tags at all. Why not allow authors t
by tenaciousDaniel 7y ago
As someone who has only used html (as in, no other xml-based UI), I'm really curious why it's necessary to even define the tags at all.
Why not allow authors to define their own names? Like
<SomeWrapper>
<SomeChild />
</SomeWrapper>
Then internal functionality can be attached to each element via attributes, like how aria roles work.
- sansnomme 7y agoCongrats on re-inventing frontend web development, I heard Facebook's hiring. This is one of the reasons people use frontend frameworks (besides state management).
- tenaciousDaniel 7y agoWhy the hostility? Should we not be open to exploring alternate ideas?
- tenaciousDaniel 7y agoI should add that I'm not literally saying that we should do this. I assume smarter people than me have thought this through, and that there are good reasons why my proposal would be a bad idea. I'd be interested to know what those reasons are.
- sansnomme 7y agoI am not intentionally being hostile, just pointing out that your stated deficiency is the one of the reasons why people migrated to component-style frameworks. It's an affirmation of your comment's validity not a criticism.
- nidificate 7y agoThis already exists. They are called custom elements. https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements https://html.spec.whatwg.org/multipage/custom-elements.html#... https://github.com/w3c/webcomponents/ https://github.com/w3c/webcomponents/ https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements https://developer.mozilla.org/en-US/docs/Web/Web_Components/...
- tenaciousDaniel 7y agoYep, 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
- warp 7y agoMaybe 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-components/customelements#extendhtml https://developers.google.com/web/fundamentals/web-component...
- Touche 7y agoThe tags are defined so that there is reasonable default behavior. For example <label> is used to label a form field. Clicking the label focuses the form field.
- tenaciousDaniel 7y agoWould be interesting though to opt in to those behaviors. So something like <MySemanticLabel label> </MySemanticLabel> Then you could mix and match functionalities. So if you have a list of labels, you could do the following: <LabelList> <LabelItem label listItem> </LabelItem> </LabelList>
- Touche 7y agoYou do opt into them, by using label. if you want an element with no behavior, that's what div and span are for.
- tenaciousDaniel 7y agoRight, but this offers two benefits: (1) semantic naming, and (2) composed functionality. So for example, if you wanted an element that exposes label behavior and list-item behavior, you could do that. With html, you have to use 2 elements: <li> <label> </li>
- Touche 7y agoYes, this is a major flaw of HTML, it is very specific about where certain elements can and cannot be, so you can't really even design a solution like the above.