Closed emezeske closed 12 years ago
Hiccup interprets boolean values in attributes differently from strings:
user> (select-options [1 2 3] 3)
([:option {:selected false} 1] [:option {:selected false} 2] [:option {:selected true} 3])
user> (html (select-options [1 2 3] 3))
"<option>1</option><option>2</option><option selected=\"selected\">3</option>"
user> (html [:option {:selected true} 3])
"<option selected=\"selected\">3</option>"
user> (html [:option {:selected false} 1])
"<option>1</option>"
So the behaviour is already correct. No need for this patch.
Interesting! I ran into this problem with crate, first, and fixed it there before cross-porting the fix to hiccup. I assumed that it was a problem here too, because I did not know about this behavior.
I patched it the same way in crate. Now I'm thinking that I should take a look at crate's boolean attribute handling, which (I guess) does not work this way. I probably should fix that instead of handling things specially for select-options.
Thanks for the quick feedback on this!
Previously, each
Note that I also amended the tests to make sure that this works properly.