Skip to content

Selector.class only matches className property, not class attribute #246

Closed

Description

@lydell

You know how you can use Html.Attributes.class multiple times to stack them? Like [ Html.Attributes.class "one", Html.Attribute.class "two" ] results in class="one two". That’s actually not an elm/html feature, it’s an elm/virtual-dom feature. It’s implemented for both the className property and the the class attribute, even though Html.Attributes.class is currently implemented only using the className property.

In other words, VirtualDom.property "className" (Json.Encode.string "my-class") and VirtualDom.attribute "class" "my-class" are equal citizens. Except in elm-explorations/test. Query.has [ Selector.class "my-class" ] only works if the class was set using className. Which it is 99.99 % of the time since Html.Attributes.class is implemented using className.

So to follow elm/virtual-dom’s lead, elm-explorations/test should do the same.

I also changed Html.Attributes.class to use the class attribute in elm/html#259. A user of my forked packages let me know that their tests stopped passing when they started using my forks. That led me to implement the following workaround to stay backwards compatible:

lydell/virtual-dom@81c070c

(That link also explains why I switched from className to class.) So that’s also a reason to do this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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