Open mandla-noredink opened 2 years ago
Query.find seems to apply sets of selectors sequentially.
The first selector produces a set of results, on which the second selector runs, etc.
So for the example <div><div><div><div class="test"></div></div></div></div>:
<div><div><div><div class="test"></div></div></div></div>
1) Query.find [ tag "div", class "test" ] will return 4 matches, all of which will be <div class="test">
Query.find [ tag "div", class "test" ]
<div class="test">
(one for each containing div and the matching div itself)
2) Query.find [ class "test", tag "div" ] will return 1 match, <div class="test">
Query.find [ class "test", tag "div" ]
This functionality is essentially chaining multiple Query.find calls in a row rather than as a single operation.
Query.find
The documentation of the function does not suggest this behaviour, and gives the impression of an and-like functionality:
Find exactly one descendant element which matches all the given selectors. If no descendants match, or if more than one matches, the test will fail.
The code responsible can be found here:
https://github.com/elm-explorations/test/blob/1.2.2/src/Test/Html/Selector/Internal.elm
Query.find seems to apply sets of selectors sequentially.
The first selector produces a set of results, on which the second selector runs, etc.
So for the example
<div><div><div><div class="test"></div></div></div></div>
:1)
Query.find [ tag "div", class "test" ]
will return 4 matches, all of which will be<div class="test">
(one for each containing div and the matching div itself)
2)
Query.find [ class "test", tag "div" ]
will return 1 match,<div class="test">
This functionality is essentially chaining multiple
Query.find
calls in a row rather than as a single operation.The documentation of the function does not suggest this behaviour, and gives the impression of an and-like functionality:
The code responsible can be found here:
https://github.com/elm-explorations/test/blob/1.2.2/src/Test/Html/Selector/Internal.elm