Cheerio: Cheerio throw error when using :first pseudo-selector

Created on 9 Oct 2014  路  1Comment  路  Source: cheeriojs/cheerio

When I try to use :first pseudo-selector in $(...).find('.descr + span i:first').text() cheerio throw error:

/home/user/project/node_modules/cheerio/node_modules/CSSselect/lib/pseudos.js:333
            throw new SyntaxError("unmatched pseudo-class :" + name);
                  ^
SyntaxError: unmatched pseudo-class :first
    at module.exports.compile [as pseudo] (/home/user/project/node_modules/cheerio/node_modules/CSSselect/lib/pseudos.js:333:10)
    at /home/user/project/node_modules/cheerio/node_modules/CSSselect/lib/compile.js:35:26
    at Array.reduce (native)
    at compileRules (/home/user/project/node_modules/cheerio/node_modules/CSSselect/lib/compile.js:33:24)
    at Array.map (native)
    at compileUnsafe (/home/user/project/node_modules/cheerio/node_modules/CSSselect/lib/compile.js:27:4)
    at select (/home/user/project/node_modules/cheerio/node_modules/CSSselect/index.js:17:43)
    at CSSselect (/home/user/project/node_modules/cheerio/node_modules/CSSselect/index.js:40:9)
    at exports.find (/home/user/project/node_modules/cheerio/lib/api/traversing.js:13:21)
    at IncomingMessage.<anonymous> (/home/user/project/app.js:105:61)

But when I use .first() selector ($(...).find('.descr + span i').first().text()) cheerio works well.

Version of cheerio is 0.17.0.

Most helpful comment

If you search our issues for the word "first", you'll find gh-408 at the top of the list. The discussion there in includes an explanation for why this feature is low priority. Use .first() instead

>All comments

If you search our issues for the word "first", you'll find gh-408 at the top of the list. The discussion there in includes an explanation for why this feature is low priority. Use .first() instead

Was this page helpful?
0 / 5 - 0 ratings

Related issues

becush picture becush  路  3Comments

francoisromain picture francoisromain  路  5Comments

miguelmota picture miguelmota  路  3Comments

Canop picture Canop  路  3Comments

dandv picture dandv  路  5Comments