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

:nth-child seemingly selects identical siblings #21

Open
other-mickk opened this issue Jan 7, 2021 · 1 comment · May be fixed by #22
Open

:nth-child seemingly selects identical siblings #21

other-mickk opened this issue Jan 7, 2021 · 1 comment · May be fixed by #22

Comments

@other-mickk
Copy link

other-mickk commented Jan 7, 2021

I have managed to reduce the situation to the following:

using Gumbo
using Cascadia

tree = parsehtml("""
<a></a>
<a class="xyz"></a>
<a></a>
""")
eachmatch(sel"a:nth-child(1)", tree.root)

This gives me the following result:

2-element Array{HTMLNode,1}:
 HTMLElement{:a}:<a></a>


 HTMLElement{:a}:<a></a>

Adding more children that are identical(ish) to the actual first sibling results in even more elements in the final array. Correct me if I’m wrong, but that shouldn’t be the case. In addition :nth-child(1) is not special, this also happens for other values of the pseudo-selector.

I’m on Julia 1.5.3, which reports the following:

]status Gumbo Cascadia
Status `~/.julia/environments/v1.5/Project.toml`
  [54eefc05] Cascadia v1.0.1
  [708ec375] Gumbo v0.8.0
@other-mickk other-mickk changed the title :first-child seemingly selects identical siblings :nth-child seemingly selects identical siblings Jan 7, 2021
@aviks
Copy link
Collaborator

aviks commented Jan 8, 2021

Thanks for the report, seems like a bug. I'll take a look when I have a moment, hopefully soon, but can't promise.

other-mickk added a commit to other-mickk/Cascadia.jl that referenced this issue Jan 15, 2021
Ensure that the `:nth-child`/`:nth-of-type` selectors find siblings
through the `Core.:(===)` operator. This is the same behaviour as
`nextSibling` and `prevSibling`.

Closes Algocircle#21.
@other-mickk other-mickk linked a pull request Jan 15, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants