davedawkins / Sutil

Lightweight front-end framework for F# / Fable. No dependencies.
https://sutil.dev
MIT License
285 stars 17 forks source link

Html Option: Attr.selected always generates #81

Open ImaginaryDevelopment opened 4 months ago

ImaginaryDevelopment commented 4 months ago

Per https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option and https://stackoverflow.com/questions/1033944/what-values-can-appear-in-the-selected-attribute-of-the-option-tag

The existence of the selected attribute on an option tag implies true So using Attr.selected false results in the option being selected. I was able to reproduce this on jsfiddle using just the following html

<select>
<option></option>
<option selected="false">I am not selected</option>
</select>

I'm not sure how easy it is to make sutil not generate the attribute when given a false value, but it seems the html spec is quite terribly designed.

Additional issues that arise from this are that instead of being able to Bind.attr you have to bind the entire element to get localized observed addition/removal of the attribute.

davedawkins commented 4 months ago

Hi, I encountered this myself recently. Let me take a look and see what I came up with. Thanks for reporting the issue.