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

When desired value is null, $.extract() fails catastrophically. #4239

Closed
Technical-13 opened this issue Nov 20, 2024 · 2 comments · Fixed by #4322
Closed

When desired value is null, $.extract() fails catastrophically. #4239

Technical-13 opened this issue Nov 20, 2024 · 2 comments · Fixed by #4322

Comments

@Technical-13
Copy link

Code:

$.extract( { links: [ { selector: 'a', value: 'href' } ] } );

On site with links that have no href:
no href
Gives:

TypeError: Cannot read properties of undefined (reading 'length')
    at parse (/home/container/node_modules/css-what/lib/commonjs/parse.js:84:29)
    at Object.select (/home/container/node_modules/cheerio-select/lib/index.js:191:68)
    at LoadedCheerio._findBySelector (/home/container/node_modules/cheerio/dist/commonjs/api/traversing.js:115:30)
    at LoadedCheerio.extract (/home/container/node_modules/cheerio/dist/commonjs/api/extract.js:39:28)
    at Function.extract (/home/container/node_modules/cheerio/dist/commonjs/static.js:165:24)
    at /home/container/commands/admin/foo.js:16:30
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@fb55
Copy link
Member

fb55 commented Nov 22, 2024

Seems like an issue in prop, where the "href" prop doesn't support elements without this value. PRs welcome!

@fb55
Copy link
Member

fb55 commented Dec 25, 2024

@Technical-13 I added some tests for what I thought would be the issue in #4322, but all of them succeed. Please provide actual markup to make it possible to replicate the issue — there is not enough here to understand your issue.

@fb55 fb55 closed this as completed in c879058 Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants