Upgrading cheerio 0.22 to 1
Breaking0.22.0 → 1.2.0Breaking18Security1Platform2Deprecated1New23Changed21Fixed41Other96
18 breaking changes and 2 platform requirement changes and a security fix.
- You can no longer call the default export or static helpers like `html` directly; load a document first.
- If you called Cheerio directly without loading a document first, you must now access it through `.default`.
- Code that read a node's `root` property must now use `parent` to reach the root node.
- Output no longer escapes non-ASCII characters automatically, so make sure you set the right content encoding.
Node.js requirement changed in 1.1.1: >= 0.6 → >=20.18.1.
Adds cheerio-select ^2.1.0, domhandler ^5.0.3, domutils ^3.2.2, encoding-sniffer ^0.2.1, parse5 ^7.3.0, parse5-htmlparser2-tree-adapter ^7.1.0, parse5-parser-stream ^7.1.2, undici ^7.19.0, whatwg-mimetype ^4.0.0.
Drops css-select, entities, lodash.assignin, lodash.bind, lodash.defaults, lodash.filter, lodash.flatten, lodash.foreach, lodash.map, lodash.merge, lodash.pick, lodash.reduce, lodash.reject, lodash.some.
Installs 22 packages in all (was 27).
Also installs iconv-lite, safer-buffer, whatwg-encoding.
No longer installs inherits, readable-stream, safe-buffer, string_decoder, util-deprecate.
Moves css-select 1.2.0 → 5.2.2, css-what 2.1.3 → 6.2.2, dom-serializer 0.1.1 → 2.0.0, domelementtype 1.3.1 → 2.3.0, domhandler 2.4.2 → 5.0.3, domutils 1.5.1 → 3.2.2, entities 1.1.2 → 4.5.0, 6.0.1, 7.0.1, htmlparser2 3.10.1 → 10.1.0, nth-check 1.0.2 → 2.1.1. Your build may pick other versions.
What you must change
cheeriohtmlcheerio.load()default export.requiredefaultload()root reference; the root node is referenced by parent.rootparentloaduseHtmlParser2cheerio/slim instead of cheerio/lib/slim.cheerio/slimcheerio/lib/slimdomhandler.domhandlerxml key.cheerio.load()xmlwithStartIndices.text() again includes script and style contents; use .prop('innerText') for the old behavior..text().prop('innerText')prevAllprevUntilparentsUntilload$.root()cheerio-selectDeprecations to plan for
load()