How do I set the selected property of an option
element with Mercury/virtual-dom?
I've tried the following, but no selected
property appears on the <option>
:
h('select', {
name: 'selectedRole',
}, [
h('option', {value: 'user', selected: true}, 'User'),
])
Instead, it results in this:
<select name="selectedRole">
<option value="user">User</option>
</select>
After some testing, it appears this is how it works with Mercury. When you set
selected
totrue
on anoption
, it does become selected even though the property isn't visible on the HTML element.However, I can only make it work in a small demo, not in my full application. Thus, there could be a bug in virtual-dom.