You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the documentation I was expecting that selectors passed to findAll would be applied to the same element:
Find the descendant elements which match all the given selectors.
This is not what I'm observing. It seems that selectors are applied one by one also to child nodes.
Example:
<p class="c1">
<a class="c2"/>
</p>
with selector findAll [Selector.class "c1", Selector.class "c2"]
I'd expect this not to match anything, but it does match one element.
I hit this issue when writing code to find a div with a certain class. The query looked like findAll [Selector.tag "div", Selector.class "c"] for HTML structure:
<div>
<div>
<div class="c">
</div>
</div>
</div>
I was very surprised to get multiple finds from findAll .
Code to illustrate the issue:
module ExampleTest exposing(exampleTest1,exampleTest2)
import Html exposing (div,a, p)
import Html.Attributes as Html
import Test.Html.Query exposing (fromHtml,findAll,count)
import Test.Html.Selector as Selector
import Test exposing (Test,test)
import Expect
exampleTest1 : Test
exampleTest1 = test "ExampleTest1 (expected 0)" <| \_ -> (div [] [ p [Html.class "c1"] [a [Html.class "c2"] []]])
|> fromHtml
|> findAll [Selector.class "c1", Selector.class "c2"]
|> count (Expect.equal <| 0)
exampleTest2 : Test
exampleTest2 = test "ExampleTest2 (expected 1)" <| \_ -> (div [] [ div [] [div [Html.class "c"] []]])
|> fromHtml
|> findAll [Selector.tag "div", Selector.class "c"]
|> count (Expect.equal <| 1)
Based on the documentation I was expecting that selectors passed to
findAll
would be applied to the same element:This is not what I'm observing. It seems that selectors are applied one by one also to child nodes.
Example:
with selector
findAll [Selector.class "c1", Selector.class "c2"]
I'd expect this not to match anything, but it does match one element.
I hit this issue when writing code to find a div with a certain class. The query looked like
findAll [Selector.tag "div", Selector.class "c"]
for HTML structure:I was very surprised to get multiple finds from
findAll
.Code to illustrate the issue:
The text was updated successfully, but these errors were encountered: