I don't know whether is it an undocumented behavior or not, when trying to load a node that is not a root, cheerio will try to parse it as a list of nodes.
I believe this commit cause such break: 2e75c2a#diff-cc0e533610b6395aec57bad8971c3692fbf20950660cc5aa5014e58333a738baR28
Minimal Example
similar usage https://stackoverflow.com/questions/39044690/cheerio-map-strange-behaviour
const cheerio = require('cheerio');
const html = `
<div class="test">
<div></div>
<div></div>
<div>
`
cheerio.load(html)('.test').map((i, e) => {
cheerio.load(e) // Break, not a root and not an array
})
If this is the desired behavior, what are the alternative ways to workaround this? Thanks!