Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the idea is rather, that you "extend" by composing primitive elements, and not that you change the primitive elements. Kind of like "composition over inheritance".


Take the html select component, you can't extend or compose this in any way. A request so common that it goes without saying is that you should be able to search for items. This is impossible to implement with the default component.

If you want to do another common thing like allow selecting multiple items, this is also impossible. It's not worth starting with the HTML one and then extending later because there is no path to do this. You have to totally scrap the HTML version so you may as well start with a JS library that does everything you need today and everything you will need tomorrow. Which you can theme to fit in with the rest of the app rather than looking like a pimple on a pumpkin that UX and end users spot and complain about instantly.


I think you misunderstand what I mean by "compose".

You can compose most HTML elements including <select> easily:

    <label>
      What do you like?
      <select name="choice">
        <option value="first">First Value</option>
        <option value="second" selected>Second Value</option>
        <option value="third">Third Value</option>
      </select>
    </label>
There you go, you did composition. The logic between those elements, how doing something with one element affects the other element, that is a different matter.

For some elements it might be invalid HTML if one is inside the other. Like a <div> inside a <span> or so.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: