web-components-examples icon indicating copy to clipboard operation
web-components-examples copied to clipboard

EditableList's attribute-based approach makes for a confusing example

Open justinfagnani opened this issue 2 years ago • 1 comments

Taking list items as individual items is a pretty awkward API that people are using as an example of why web components have a bad API. It's a poor argument - you can make a similar component API in any framework - but there's no reason IMO to design a component this way. It would be far more ergonomic to take a list of items as a property, a JSON array as an attributes, and/or a list of child elements.

justinfagnani avatar Oct 25 '23 17:10 justinfagnani

Thanks for reporting. Is the suggestion to do something like this?

<editable-list
    title="TODO"
    items='["one", "two", "three"]'
    ...
></editable-list>

To help anyone reading through / investigating:

  • demo: https://mdn.github.io/web-components-examples/editable-list/
  • example src: https://github.com/mdn/web-components-examples/tree/main/editable-list

bsmth avatar Mar 18 '24 09:03 bsmth