diff --git a/src/soup.ml b/src/soup.ml index 992edd1..2940c5b 100644 --- a/src/soup.ml +++ b/src/soup.ml @@ -598,6 +598,7 @@ struct | Content s -> texts node |> String.concat "" |> has_substring s | Has selector -> descendants node + |> filter (fun descendant -> not (is_text descendant)) |> filter (fun descendant -> matches_simple_selector descendant selector) |> count |> fun count -> count > 0 diff --git a/test/test.ml b/test/test.ml index c3abcb3..1dcae66 100644 --- a/test/test.ml +++ b/test/test.ml @@ -127,6 +127,8 @@ let suites = [ test "ol:has([id=one])" 0; test "li:has([id=one])" 0; test ":has(.odd)" 4; + test ":has(ul)" 2; + test ":has(caption)" 0; test ("html:root > body.lists[class~=lists] > ul > li#one:nth-child(1) " ^ "+ li#two")