Skip to content

nth:child not limiting to range correctly in p:nth-child(n+2):nth-child(-n+2) #1147

Closed

Description

@agarkoff

When processing a page http://ymammy.ru/category/dlya-mam/ , nth-child(2) does not work correctly.
http://skrinshoter.ru/i/211118/U0Lo9X7F.png

Activity

  1. bluetata commented on Dec 10, 2018

    @bluetata
  2. ny83427 commented on Dec 14, 2018

    @ny83427
    Contributor

    When processing a page http://ymammy.ru/category/dlya-mam/ , nth-child(2) does not work correctly.
    http://skrinshoter.ru/i/211118/U0Lo9X7F.png

    I suggest that you go to https://try.jsoup.org/ and save it so that Jonathan or others can investigate effectively. Since the live url would change content and the screenshot also didn't provide necessary context information. At least you should provide input, expected output and actual output.

    If this information can be provided I would also like to have a try to fix it - if it's proved to be a real issue.

  3. laxika commented on Dec 27, 2018

    @laxika

    Yeah, can you please send a fragment of the HTML so people can look into it/investigate? Without knowing what's in the "li" variable it's hard to see why JSoup fails. I can come up with multiple fragments that could work with the screenshot provided.

  4. Fachher commented on Mar 12, 2020

    @Fachher

    The selector does not work correctly, if there are hidden elements present such as
    <input type="hidden"/>

  5. jhy commented on Jan 4, 2021

    @jhy
    Owner

    Please provide a fragment and the selector so anyone can replicate this. Best to use try.jsoup as mentioned.

  6. added
    needs-more-infoMore information is needed from the reporter to progress the issue
    on Jan 4, 2021
  7. utosh commented on Jun 14, 2021

    @utosh
    <html>
    <head>
    <title>Try jsoup</title>
    </head>
    <body>
    <p>row1</p>
    <p>row2</p>
    <p>row3</p>
    <p>row4</p>
    </body>
    </html>

    selector: p:nth-child(n+2):nth-child(-n+2)

    I want to get 2nd <p> tag only but returns row2,3,4.
    Instead of using nth-child(-n+x), I could get expected result by p:nth-child(n+2):lt(2).
    thanks!

  8. removed
    needs-more-infoMore information is needed from the reporter to progress the issue
    on Jan 6, 2023
  9. changed the title [-]nth:child(2) not correct[/-] [+]nth:child not limiting to range correctly in `p:nth-child(n+2):nth-child(-n+2)`[/+] on Jan 6, 2023
  10. jhy commented on Jan 6, 2023

    @jhy
    Owner

    (Confirmed in browser that p:nth-child(n+2):nth-child(-n+2) will select just the second row)

  11. added
    bugA confirmed bug, that we should fix
    on Jan 6, 2023
  12. self-assigned this
    on Jan 14, 2025
  13. added
    fixedAn {bug|improvement} that has been {fixed|implemented}
    on Jan 14, 2025
  14. added this to the 1.19.1 milestone on Jan 14, 2025
  15. jhy commented on Jan 14, 2025

    @jhy
    Owner

    Thanks all, fixed, finally :)

  16. added a commit that references this issue on Jan 15, 2025
    62674f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugA confirmed bug, that we should fixfixedAn {bug|improvement} that has been {fixed|implemented}

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions