elm / svg

Fast SVG in Elm
https://package.elm-lang.org/packages/elm/svg/latest
BSD 3-Clause "New" or "Revised" License
147 stars 20 forks source link

Svg.Attributes.style not consistent with Html.Attributes.style #21

Open jhrcek opened 7 years ago

jhrcek commented 7 years ago

There is a discrepancy in how elm-lang/html and elm-lang/svg packages work with style attribute. This attribute is declared with different types in each package:

Html.Attributes.style : List (String, String) -> Attribute msg versus Svg.Attributes.style : String -> Attribute msg

This is not problem per se. What I find problematic though is that when multiple style attributes are present the list of attributes of one element, in Html the styles are combined, whereas in Svg the "last one wins". See the following code fragment on ellie for illustration of the issue.

This typically causes problems when you have reusable view function and want to provide additional attributes like so:

myWidget : List (Attribute msg) -> Svg msg
myWidget additionalAttributes = ...

Wouldn't it make sense to unify this and have Svg.Attributes.style have the same type and behavior as Html.Attributes.style?

See an example fix I had to do in a project I'm working on to work around this problem.

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.