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

Html.Attributes.attribute renaming of attribute to data-attribute is not documented #185

Open robx opened 5 years ago

robx commented 5 years ago

My working elm 0.18 code

capturePointerDown : Html.Attribute msg
capturePointerDown =
    Html.Attributes.attribute
        "onpointerdown"
        "event.target.setPointerCapture(event.pointerId);"

fails in 0.19 because it sets the data-onpointerdown attribute instead of onpointerdown.

I suspect this is an intentional don't-let-me-shoot-myself-in-the-foot change, but in that case, it should be mentioned in the docs: https://package.elm-lang.org/packages/elm/html/latest/Html-Attributes#attribute

robx commented 5 years ago

Here's a relevant stackoverflow question: https://stackoverflow.com/questions/53456798/elm-attribute-onerror-adds-data-onerror-attribute-instead

robx commented 5 years ago

For my specific use case, ports should work fine as shown in https://github.com/mpizenberg/elm-pointer-events/tree/4.0.0/examples/Pointer. I'll update the title to ask for this behaviour to be documented.

ChristophP commented 5 years ago

That only happens for fields that start with on to prevent javascript injection. https://github.com/elm/virtual-dom/blob/master/src/Elm/Kernel/VirtualDom.js#L282-L285 But it still would be good to mention it in the docs a bit more obviously.