I have a table with some CSS class. I use the same CSS class name to denote the tr and td elements in the table. When using Query.find to find my table, this works: Query.find [ class "myClassName", tag "table" ], and this doesn't because it'll find all children with that class: Query.find [ tag "table", class "myClassName" ].
This is either a bug, or missing documentation. Based on the documentation for find I expect that the selectors are in an AND relationship, thus the order should not matter.
Full example (you can see that one of the tests passes and the other fails):
Example.elm
module Example exposing (..)
import Test exposing (Test, describe, test)
import Test.Html.Query as Query
import Test.Html.Selector as Selector exposing (tag, class)
import Html exposing (Html, div, table, tr)
import Html.Attributes as Attributes
suite : Test
suite =
describe "This unexpected behavior in Test.Html.Query"
[ test "selecting the tag and class one way" <|
\() ->
tableWithClassName
|> Query.fromHtml
|> Query.find [ class "myClassName", tag "table" ]
|> Query.has [ tag "table" ]
, test "selecting the tag and class the other way" <|
\() ->
tableWithClassName
|> Query.fromHtml
|> Query.find [ tag "table", class "myClassName" ]
|> Query.has [ tag "table" ]
]
tableWithClassName : Html msg
tableWithClassName =
div []
[ table
[ Attributes.class "myClassName" ]
[ tr [ Attributes.class "myClassName" ] [] ]
]
I have a
table
with some CSS class. I use the same CSS class name to denote thetr
andtd
elements in the table. When usingQuery.find
to find my table, this works:Query.find [ class "myClassName", tag "table" ]
, and this doesn't because it'll find all children with that class:Query.find [ tag "table", class "myClassName" ]
.This is either a bug, or missing documentation. Based on the documentation for
find
I expect that the selectors are in an AND relationship, thus the order should not matter.Full example (you can see that one of the tests passes and the other fails):
Example.elm
elm-package.json: