#5541·cheerio

filter() and children() ignore custom pseudos and quirksMode

Author: jakezwangCreated Sep 18, 2026Updated Sep 18, 2026

filter() and traversal methods that accept a selector, such as children(), ignore the pseudos option passed to load(). The same selector works with find() and is().

javascript
import * as cheerio from 'cheerio';

const $ = cheerio.load('<ul><li class="apple">Apple</li><li>Pear</li></ul>', {
  pseudos: { fruit: '.apple' },
});

$('ul').find(':fruit').text(); // 'Apple'
$('li').is(':fruit'); // true
$('li').filter(':fruit'); // throws: Unknown pseudo-class :fruit
$('ul').children(':fruit'); // throws: Unknown pseudo-class :fruit

Both filtering operations should select the apple element. quirksMode is also ignored: with { quirksMode: true }, filtering by .APPLE fails to match class="apple".

Reproduced on current main (ef03a7abbed8b460deef01c4878b6cee7c44322d) with Node.js 24.4.1. filterArray() forwards only xmlMode and the document root, dropping the other selector options. I have a focused fix that forwards the options and regression tests for both call paths.