Skip to content

Query Throws when the element exists #224

Description

@L1lith

I try running this query but it seems to fail incorrectly.

doc.querySelector(".band:nth-of-type(3) .col-md-4:nth-of-type(2) h2")

Error Message:

TypeError: Cannot read properties of null (reading 'length')
    at nthOfType (/Users/ADMIN/projects/melonjs.org/node_modules/css-select/lib/pseudo-selectors/filters.js:81:42)
    at cachedDescendant (/Users/ADMIN/projects/melonjs.org/node_modules/css-select/lib/general.js:71:55)
    at tag (/Users/ADMIN/projects/melonjs.org/node_modules/css-select/lib/general.js:48:60)
    at cachedDescendant (/Users/ADMIN/projects/melonjs.org/node_modules/css-select/lib/general.js:71:55)
    at tag (/Users/ADMIN/projects/melonjs.org/node_modules/css-select/lib/general.js:48:60)
    at findOne (/Users/ADMIN/projects/melonjs.org/node_modules/node-html-parser/dist/matcher.js:68:13)
    at findOne (/Users/ADMIN/projects/melonjs.org/node_modules/node-html-parser/dist/matcher.js:74:24)
    at findOne (/Users/ADMIN/projects/melonjs.org/node_modules/node-html-parser/dist/matcher.js:74:24)
    at findOne (/Users/ADMIN/projects/melonjs.org/node_modules/node-html-parser/dist/matcher.js:74:24)
    at findOne (/Users/ADMIN/projects/melonjs.org/node_modules/node-html-parser/dist/matcher.js:74:24)

When I run the same query in my browser while browsing the HTML page, it returns the <h2> element successfully.

Relevant source code & HTML files

Activity

  1. L1lith commented on Nov 14, 2022

    @L1lith
    Author

    @taoqf It appears I'm still getting that error, I'm also getting it with this query
    .band:nth-of-type(3) .col-md-4:nth-of-type(3) blockquote p
    I do admit the query is quite complicated, is this something the library is not intended for?

  2. taoqf commented on Nov 15, 2022

    @taoqf
    Owner

    So sorry for that, I did not see the html file.

  3. reopened this on Nov 15, 2022
  4. L1lith commented on Nov 15, 2022

    @L1lith
    Author

    So sorry for that, I did not see the html file.

    Thank you 🥳 everything worked like a charm!

  5. added 2 commits that reference this issue on Jan 5, 2026
    fc367fa
    0719bf0
  6. reopened this on Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions