0

I am using the following library: https://github.com/hyperhype/hyperscript

The following code:

h('input', { list: "list-id"}),
h('datalist', { id: "list-id" }, [
    h('option', ["Option 1"]),
])`

results in:

<input>
<datalist id="list-id">
    <option>Option 1</option>
</datalist>

The input element lacks the list property i.e. It should look like <input list="list-id">

What am I doing wrong?

Ivan
  • 1,967
  • 4
  • 34
  • 60
  • _Note that hyperscript sets properties on the DOM element object, not attributes on the HTML element._ – Randy Casburn Mar 11 '19 at 01:41
  • Ok, so what am I doing wrong? `list` is a valid property of the `input` element object. – Ivan Mar 11 '19 at 02:38
  • 2
    You aren't doing anything _wrong_. I believe you've chosen to use an API that doesn't fully support HTML 5 attributes and that has literally NO documentation to support you (I suppose some would consider that choice to be _wrong_). Glad you got it worked out. – Randy Casburn Mar 11 '19 at 02:47

1 Answers1

1

I managed to solve it with:

h('input', { attributes: { 'list': "list-id" } })
h('datalist', { id: "list-id" }, [
    h('option', ["Option 1"]),
])`
Ivan
  • 1,967
  • 4
  • 34
  • 60
  • 2
    Awesome. good for you. Based upon the complete lack of documentation, I suppose this isn't the end of your troubles. Good Luck to you. – Randy Casburn Mar 11 '19 at 02:46
  • @RandyCasburn Yeah, so far I've managed to do things. The library is pretty small and is part of the `virtual-dom` one. I am trying to implement `The Elm Architecture` with [vanilla Javascript](https://github.com/8483/vanilla-js-tea-todo), as I don't like the bloat of frameworks like React. – Ivan Mar 11 '19 at 03:57