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

Context ignored on selection #70

Closed
Trindaz opened this issue Jun 30, 2012 · 4 comments
Closed

Context ignored on selection #70

Trindaz opened this issue Jun 30, 2012 · 4 comments

Comments

@Trindaz
Copy link

Trindaz commented Jun 30, 2012

Forgive me if I've misread the docs, but I can't understand how this kind of result would be useful / intentional:

    var myHTML = '<tr><a>myLink1</a></tr><tr><a>myLink2</a></tr>';
    var $ = cheerio.load(myHTML);
    var rows = $('tr');
    var links = $('a', rows.get(0));
    console.log("There are " + links.length + " links in the first row")

gives me

There are 2 links in the first row.

I'm using the first row as context so I should only get 1 link for that first row. I also tried rows[0] instead of rows.get(0) to no avail.

Is this a bug?

@kuhnza
Copy link

kuhnza commented Aug 21, 2012

I'm experiencing the same issue.

@matthewmueller
Copy link
Member

Oh that's odd - I will look into this.

@kuhnza
Copy link

kuhnza commented Aug 21, 2012

Thanks Matt. I probably should have mentioned that it appears to be searching from the top/root of the DOM rather than from the root of the context object/selector.

@fb55
Copy link
Member

fb55 commented Apr 8, 2014

Moved to fb55/css-select#21.

@fb55 fb55 closed this as completed Apr 8, 2014
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

No branches or pull requests

4 participants