Skip to content

Releases: cheeriojs/cheerio

v1.0.0-rc.12

26 Jun 13:35
Compare
Choose a tag to compare

Bugfix release. Fixed issues:

  • Align prop undefined handling with jQuery by @fb55 in #2557
  • Allow deep imports of cheerio/lib/utils by @blixt in #2601

New Contributors

Full Changelog: v1.0.0-rc.11...v1.0.0-rc.12

v1.0.0-rc.11

20 May 15:27
Compare
Choose a tag to compare

cheerio@1.0.0-rc.11 is hopefully the last RC before the 1.0.0 release of Cheerio. There are two APIs that will be added for the next major release: An exract method (#2523) and NodeJS specific loader methods (#2051). These are still in flux and I'd appreciate feedback on the proposals.

A big thank you to everyone that contributed to this release! This includes code contributors, as well as the amazing financial support on GitHub Sponsors!

Under the hood, a lot of work for this release went into updating parse5, cheerio's default HTML parser. Have a look at parse5's release notes to see what has changed there.

Breaking

  • Cheerio is now a dual CommonJS and ESM module. That means that deep imports will now fail in newer versions of Node. #2508
  • script and style contents are added again in .text() #2509
    • To keep the old behavior, switch .text() to .prop('innerText')
  • The TypeScript types inherited from upstream dependencies have changed. #2503
    • Node types are now using tagged unions, which will make consumption a bit easier.

Features

  • Relevant options are now forwarded to cheerio-select #2511
  • For the .prop() method:
    • Add textContent and innerText props #2214
    • Users can now specify a baseURI option, which will lead to href and src props to be resolved as URLs. #2510
  • Added a slim export, which will always use htmlparser2 #1960

Fixes

  • Have text turn passed values to strings #2047
  • Include undefined in the return type of get by @glen-84 in #2392
  • Recognise comments as HTML #2504
  • Add missing undefined return value #2505
  • Export missing static methods #2506
  • Have style parsing add malformed fields to previous field #2521

Refactor

  • Use domutils module directly #1928
  • Hand-roll isHTML #1935
  • Move initialization logic to load #1951
  • Only return elements in closest #2057
  • Remove unnecessary code, be more explicit #2279
  • Use stricter TS, ESLint configs #2507
  • Update exported values #2512

Development Experience

Docs

New Contributors

Full Changelog: v1.0.0-rc.10...v1.0.0-rc.11

v1.0.0-rc.10

08 Jun 15:49
Compare
Choose a tag to compare

Fixes:

Documentation:

Refactors:

v1.0.0-rc.9...v1.0.0-rc.10

v1.0.0-rc.9

06 May 15:57
Compare
Choose a tag to compare

Port to TypeScript

Cheerio has been ported entirely to TypeScript (in #1816)! This eliminates a lot of edge-cases within Cheerio and will allow you to use Cheerio with confidence. This release also features a new documentation website based on TypeDoc, allowing you to quickly navigate all available methods: https://cheerio.js.org


Breaking change: If you were using the function exported by Cheerio directly instead of first load()ing a document, you will now have to update the require to use the default export.

- const cheerio = require("cheerio");
+ const cheerio = require("cheerio").default;

cheerio('div', dom)

Please note that this way of using Cheerio is deprecated and might be removed in a future version. Please consider updating your code to:

const cheerio = require("cheerio");

const $ = cheerio.load(dom)
$('div')

Note: Cheerio uses template literal types to determine return types. These are available starting with TypeScript 4.1, so you might have to bump your TypeScript version.

For TypeScript types, Cheerio now implements the ArrayLike<T> interface. That means that Cheerio instances can contain objects of arbitrary types, but not all methods can be called on them.

The TypeScript compiler will figure out what structures you are operating on:

  • When calling a loaded Cheerio instance with an HTML string like $('<div>'), it will product a Cheerio<Node> type.
    • Node is the base class for DOM elements and includes eg. comment and text nodes.
  • When calling Cheerio with a selector like $('.foo'), it will produce a Cheerio<Element>, as only Elements can be part of the result set.
    • Element is the class representing tags.
  • You can still use $('...').map() to map to arbitrary values, and will get a compiler error when trying to call method that are not supported.
    • Eg. $('.foo').map((i, el) => $(el).text()).attr('test') will no longer be possible, as .attr is not allowed to be called on a Cheerio<string>.

This release does not contain other changes to functionality. Feedback is greatly appreciated; if you encounter a problem, please file an issue!

v1.0.0-rc.6...v1.0.0-rc.9

v1.0.0-rc.8

06 May 15:35
Compare
Choose a tag to compare
v1.0.0-rc.8 Pre-release
Pre-release

Second botched release. Please use v1.0.0-rc.9 instead.

v1.0.0-rc.7

06 May 15:28
Compare
Choose a tag to compare
v1.0.0-rc.7 Pre-release
Pre-release

Published without a lib directory — please ignore.

v1.0.0-rc.6

08 Apr 22:21
Compare
Choose a tag to compare

Breaking:

  • Fixed the ordering of the output of several methods, including prevAll, prevUntil and parentsUntil. The new order matches jQuery.

This release contains three breaking changes inherited from dependencies.

  • Selectors (see css-select@4.0.0):
    • Several pseudo selectors are now stricter, in line with the HTML spec.
    • Some attributes are now case-insensitive based on the HTML spec.
  • DOM:
    • In XML mode, all elements will have type: 'tag'.

New features:

Types:

Bug fixes:

Documentation updates:

Refactors:

CI:

Test changes:

Commit Range:
v1.0.0-rc.5...v1.0.0-rc.6

v1.0.0-rc.5

21 Dec 21:06
Compare
Choose a tag to compare

Hotfix release

  • fix(package): Use cheerio-select-tmp until naming issue is resolved 3751929

v1.0.0-rc.4...v1.0.0-rc.5

v1.0.0-rc.4

21 Dec 20:34
Compare
Choose a tag to compare

Welcome to cheerio@1.0.0-rc.4! This is the last pre-release before a full 1.0.0 release — please make sure to test this release and report any issues you might find.

This release was made possible by our supporters on Open Collective. If you want to support this project going forward, have a look at sponsorship options!

Breaking:

  • After upgrading parse5, cheerio temporarily has a minimum Node version of Node 6. See #1585 for details.
  • Use the parser's DOM without modifications (#1559 by @fb55)
    • Nodes no longer have a root reference. The root node is now referenced by the parent property.
  • Use parse5 to serialize the DOM (04091a4 by @fb55)
    • We will no longer encode non-ASCII characters by default. Please make sure that you pass on the appropriate content encoding.

New Features:

Bug Fixes:

Other notable changes:

1.0.0-rc.2...v1.0.0-rc.4

1.0.0-rc.3

15 Dec 00:18
1.0.0-rc.3
Compare
Choose a tag to compare

This release corrects a test expectation that was fixed by one of the project's dependencies.