elm / html

Use HTML in Elm!
https://package.elm-lang.org/packages/elm/html/latest/
BSD 3-Clause "New" or "Revised" License
395 stars 99 forks source link

Value vs Attribute "value" #209

Open jalandis opened 4 years ago

jalandis commented 4 years ago

There is difference between the Html generated by Html.Attributes.attribute "value" "" and Html.Attributes.value "" that leads to some unexpected behaviour.

To illustrate the issue, here is an example select element with 2 options.
https://ellie-app.com/8xvjpZt6NwSa1

select 
  [ onInput Pick ] 
  [ option [ value "" ] [ text "Empty Value" ]
  , option [ selected True, attribute "value" "" ] [ text "Empty Attribute Value" ]
  ]

Switching options 3 times produces the following inconsistent messages.

Pick "Empty Value"
Pick ""
Pick ""
jmpavlick commented 2 years ago

This seems to be more general than just Html.Attributes.value.

Html.Attributes.selected is broken, too:

For the following code:

main =
    Html.div []
        [ Html.select []
            [ Html.option [ Attr.selected True ] [ Html.text "Value A" ]
            , Html.option [] [ Html.text "Value B" ]
            ]
        ]

No selected value is added to the DOM.

Ellie: https://ellie-app.com/h4rZFfTtWj3a1