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

Open
Technical-13 opened this issue Nov 20, 2024 · 1 comment
Open

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants