Extend `fl-contains` to mach on children text as well
revati opened this issue · 1 comments
revati commented
Feature goal
Extend fl-contains
to mach on children text as well.
"<div>Some</div>"
|> Floki.parse_document!()
|> Floki.find("div:fl-contains('Some')")
|> IO.inspect(label: :first)
# Output: first: [{"div", [], ["Some"]}]
"<div><span>Some</span></div>"
|> Floki.parse_document!()
|> Floki.find("div:fl-contains('Some')")
|> IO.inspect(label: :second)
# Output: second: []
# Desired output: [{"div", [], [{"span", [], ["Some"]}]}]
philss commented
Hey @revati
You actually can archive similar results using a descendant combinator with the "all" selector ("*
").
Please try:
"<div><span>Some</span></div>"
|> Floki.parse_document!()
|> Floki.find("div *:fl-contains('Some')")
|> IO.inspect(label: :second)
# Output: second: [{"span", [], ["Some"]}]
# Desired output: [{"div", [], [{"span", [], ["Some"]}]}]