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

Query Throws when the element exists #224

Closed
L1lith opened this issue Oct 15, 2022 · 3 comments
Closed

Query Throws when the element exists #224

L1lith opened this issue Oct 15, 2022 · 3 comments

Comments

@L1lith
Copy link

L1lith commented Oct 15, 2022

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

@L1lith
Copy link
Author

L1lith commented Nov 14, 2022

@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?

@taoqf
Copy link
Owner

taoqf commented Nov 15, 2022

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

@taoqf taoqf reopened this Nov 15, 2022
@taoqf taoqf closed this as completed in 0719bf0 Nov 15, 2022
@L1lith
Copy link
Author

L1lith commented Nov 15, 2022

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

Thank you 🥳 everything worked like a charm!

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

No branches or pull requests

2 participants