Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend fl-contains to mach on children text as well #382

Open
revati opened this issue Feb 2, 2022 · 1 comment
Open

Extend fl-contains to mach on children text as well #382

revati opened this issue Feb 2, 2022 · 1 comment
Labels

Comments

@revati
Copy link

revati commented Feb 2, 2022

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"]}]}]
@revati revati added the Feature label Feb 2, 2022
@philss
Copy link
Owner

philss commented Feb 2, 2022

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"]}]}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants