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

textNode not passed into .filter method #1867

Closed
jeroentvb opened this issue May 13, 2021 · 2 comments · Fixed by #1870 · 4 remaining pull requests
Closed

textNode not passed into .filter method #1867

jeroentvb opened this issue May 13, 2021 · 2 comments · Fixed by #1870 · 4 remaining pull requests

Comments

@jeroentvb
Copy link

jeroentvb commented May 13, 2021

The .filter(function) method only gets DOM elements passed in, while .each(function) gets all DOM nodes, including text nodes. This used to work in RC-5, but doesn't in RC-9. And as far as I could tell, this isn't expected behaviour, because I wasn't able to find info indicating that it is in the jQuery docs.

Consider the following html snippet:

<body>
    <div style="color: black;">Hello</div>
    world
    <small>!</small>
</body>

If I were to select the body and .filter its contents, I won't get the world text node in my filter loop. Whereas I will get the world text node in my loop if I use .each on the contents of the body.

I've created a repo demonstrating my findings.

Edit: just checked, it also used to work with RC-6. That means it stopped working with the RC-9 release.

@fb55
Copy link
Member

fb55 commented May 15, 2021

Thanks for reporting! I've opened #1870 with a fix.

@sehrgut
Copy link

sehrgut commented May 17, 2021

I commented on #1870 as well, but just for visibility: this should also iterate over comment nodes, which that commit still appears not to do.

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