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

fix(traversing): Make filter work on all collections #1870

Merged
merged 2 commits into from
May 17, 2021
Merged

fix(traversing): Make filter work on all collections #1870

merged 2 commits into from
May 17, 2021

Conversation

fb55
Copy link
Member

@fb55 fb55 commented May 15, 2021

Fixes #1867

@sehrgut
Copy link

sehrgut commented May 17, 2021

This should also iterate over comment nodes. It doesn't appear to do that.

@fb55
Copy link
Member Author

fb55 commented May 17, 2021

@sehrgut This PR removes the restrictions for all set types. With this PR, you can iterate over a Cheerio<number> without issue. TS doesn't like this (yet), but this runs in pure JS:

$([1,2,3,4,5]).filter((_,n)=>n%2).toArray()
//=> [1,3,5]

@fb55 fb55 enabled auto-merge (squash) May 17, 2021 12:31
@fb55 fb55 merged commit fb8d31e into main May 17, 2021
@fb55 fb55 deleted the fix/filter branch May 17, 2021 12:34
@sehrgut
Copy link

sehrgut commented May 17, 2021

Ah! I see that now. I think I assumed from the new imports list import { Node, Element, Text, isText } from 'domhandler'; that those would be the only ones picked up by AcceptedFilters<T>. Thank you!

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

Successfully merging this pull request may close these issues.

textNode not passed into .filter method
2 participants