hyperhype / hyperscript

Create HyperText with JavaScript.
MIT License
2.64k stars 109 forks source link

support proper <label> attributes #74

Open NHQ opened 7 years ago

NHQ commented 7 years ago

the label element has an attribute "for", which points to an input element label.for == ID

hyperscript scrubs the for attribute out of labels

h('label', {for: "someID"}, text)
gandhiShepard commented 6 years ago

The correct JS attribute to use is htmlFor. To correct the snippet above, write this:

h('label', {htmlFor: "someID"}, text)

Read more: https://stackoverflow.com/questions/15750290/setting-the-html-label-for-attribute-in-javascript?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

kolbasik commented 5 years ago

Or you can specify the attrs property to tell hyperscript sets the following as attributes:

h('label', { attrs: { for: "someID" } }, text)

But I would go with the suggestion above.