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

Adjacent sibling selectors broken #1095

Closed
ghost opened this issue Oct 15, 2017 · 4 comments · Fixed by #1583
Closed

Adjacent sibling selectors broken #1095

ghost opened this issue Oct 15, 2017 · 4 comments · Fixed by #1583

Comments

@ghost
Copy link

ghost commented Oct 15, 2017

Cheerio adjacent sibling selectors aren't working properly. This is the case for both + and ~

let html = `
<div class="foo">My List</div>
<ul>
  <li>aaa</li>
  <li>bbb</li>
  <li>ccc</li>
</ul>
`
const cheerio = require('cheerio')

let $ = cheerio.load(html)

let data = $('.foo').get().map(div => {
  return {
    title: $(div).text(),
    list: $(div).find('+ ul li').get().map(li => $(li).text())
  }
})

console.log(data)

// [ { title: 'My List', list: [] } ]

Also if anybody knows of any projects that are more faithful to jQuery I'd love to hear about it. Thanks.

@dbuezas
Copy link

dbuezas commented Dec 3, 2017

you can use jQuery or Sizzle with JSDom. It is slower but it works great.

@fb55
Copy link
Member

fb55 commented Dec 22, 2020

This should be resolved with the latest release.

@fb55 fb55 closed this as completed Dec 22, 2020
@ghost
Copy link
Author

ghost commented Dec 22, 2020 via email

@fb55
Copy link
Member

fb55 commented Dec 22, 2020

Actually, this was not fixed yet. I've opened #1583 with a proper fix.

@fb55 fb55 reopened this Dec 22, 2020
fb55 added a commit that referenced this issue Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants