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

Add convenience methods to iterate only over child and descendant elements instead of all nodes. #158

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

adamreichold
Copy link
Member

Note that we cannot easily extend NodeRef as the types comes from ego-tree, not scaper.

(We could use an extension trait and such, but I think starting from an ElementRef is common enough, especially when using these iterators to stay within the elements.)

Closes #157

@Caellian
Copy link

Caellian commented Nov 4, 2023

Why not add the trait (e.g. TraverseElements) to extend NodeRef as well and then implement added functions for ElementRef through that?

I wouldn't say it closes #157 as it currently adresses only half of the suggestion.

@adamreichold
Copy link
Member Author

adamreichold commented Nov 4, 2023

Why not add the trait (e.g. TraverseElements) to extend NodeRef as well and then implement added functions for ElementRef through that?

I wouldn't say it closes #157 as it currently adresses only half of the suggestion.

As written above

(We could use an extension trait and such, but I think starting from an ElementRef is common enough, especially when using these iterators to stay within the elements.)

i.e. I don't think the additional complexity is warranted especially since one will most likely stay within the ElementRef-typed world using these traversal helpers.

@cfvescovo
Copy link
Member

LGTM

@cfvescovo cfvescovo merged commit 509bcb3 into rust-scraper:master Nov 9, 2023
5 checks passed
@adamreichold adamreichold deleted the element-iterators branch November 9, 2023 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make element traversal more convenient
3 participants