I’m an Elm newbie happily working my way through Elm in Action by Richard Feldman
(Code below is, I think, © 2017 Manning Publications. No infringement intended.)
Following a ‘Tip’ suggestion to improve the code (Section 3.2.4) I added a checked attribute to a radio button input so that the buttons correctly represent the model’s initial state on page load. And it works.
However, when I use Chromium’s inspector, my radio inputs all look like this:
<input type="radio" name="size">
None of them, including the one generated with checked True, have a checked attribute.
My question is:
What determines which attributes (and tags?) appear in the viewable page elements, and which will only exist in the DOM? Or am I misinterpreting what’s happening?
The (relevant) code:
...
viewSizeChooser : ThumbnailSize -> Html Msg
viewSizeChooser size =
label []
[ input [ type_ "radio", name "size", checked (isDefaultSize size), onClick (SetSize size) ] []
, text (sizeToString size)
]
isDefaultSize : ThumbnailSize -> Bool
isDefaultSize size =
size == initialModel.chosenSize
...
Inspector output:
...
<div id="choose-size">
<label>
<input type="radio" name="size">
small
</label>
<label>
<input type="radio" name="size">
medium
</label>
<label>
<input type="radio" name="size">
large
</label>
</div>
...