Skip to content

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

@jhrcek

Description

@jhrcek

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions