-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
$(selector, context) uses wrong context #193
Comments
Is this maybe related to #70? |
This certainly sounds unintentional. |
This sounds like the problem I've been having in cheerio 0.10.5 and up. It worked in 0.10.4. I also commented about this on #167. |
I tried to implement proper context handling in CSSselect yesterday, but apparently my approach didn't handle all cases. When I find some time, I'll have a second look at it. |
I'm experiencing this issue too. I'm trying to do something similar to the following and it seems like it's using the parent or root as the context. $("section").each(function(index, element) {
var url = $("a", this).attr("href");
}); |
@ssmout is right, it does work in 0.10.4. I suppose I will use this for now. |
This issue is still present in 0.11. Using version 0.10.4 still works. |
Fixed in a47bc68. I think this warrants bumping to 0.12.0, @matthewmueller. |
👍 This is a breaking change, so a note in the README would be nice too. |
Or in History.md. |
Updated to 0.12.0. Thanks guys |
I'm not sure whether this is intended behavior: When using
$(selector, context)
, cheerio uses the parent context instead of the provided one. This leads to unintentionally searching the object's siblings too.I find this confusing, because jQuery uses the context directly - this means it behaves exactly like calling find:
(from the jQuery Docs)
The text was updated successfully, but these errors were encountered: