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

Failing test: Comma selectors are evaluated independently #14

Closed
wants to merge 1 commit into from

Conversation

j-f1
Copy link

@j-f1 j-f1 commented Apr 30, 2022

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

This PR adds a failing test demonstrating what I think is a bug. I wanted to use hast-util-select to assign the correct heading path (h1.textContenth2.textContentp) to paragraphs on a document. But it looks like unist-util-select’s selectAll essentially evaluates selector.split(',').flatMap(selectAll), resulting in out-of-order results.

I noticed that wrapping my selector in :matches() causes results to be emitted in the correct order (although doing this prevents me from using nesting selector combinators like >, so it doesn’t work for my use case).

I think this should either be fixed (so that the ordering of results from :matches(a, b) and a, b are the same) or documented as a limitation.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Apr 30, 2022
@j-f1 j-f1 changed the title Comma selectors are evaluated independently Faling test: Comma selectors are evaluated independently Apr 30, 2022
@j-f1 j-f1 changed the title Faling test: Comma selectors are evaluated independently Failing test: Comma selectors are evaluated independently Apr 30, 2022
@wooorm
Copy link
Member

wooorm commented May 2, 2022

Thanks for the repro. I think it might the same issue as syntax-tree/unist#66 (reply in thread).

wooorm added a commit to syntax-tree/hast-util-select that referenced this pull request Dec 30, 2022
@wooorm
Copy link
Member

wooorm commented Dec 30, 2022

Well, that was very hard to solve. The whole architecture had to be different.
I managed to solve it in hast-util-select, should soon land here.

@wooorm wooorm closed this in 258beff Dec 31, 2022
@github-actions

This comment has been minimized.

@wooorm wooorm added the 💪 phase/solved Post is done label Dec 31, 2022
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Dec 31, 2022
@wooorm
Copy link
Member

wooorm commented Dec 31, 2022

Fixed!

@j-f1 j-f1 deleted the order-test branch December 31, 2022 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

Successfully merging this pull request may close these issues.

2 participants